#1000
Unrated
LJUTNJA
시간 제한
1s
메모리 제한
32MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Author: Adrian Satja Kurdija

Children in a kindergarten have received a large sack containing M candies. It has been decided that the candies are to be distributed among N children. Each child has stated the number of candies that it wants. If a child isn’t given the amount of candy it wants, it will get angry. In fact it’ll get angrier for each candy it is deprived of. Some speculate that it’s anger will be equal to the square of the number of candy it is deprived of. For instance, if Mirko states that he wants 32 candies but receives only 29, he would be missing 3 candies, so his anger would be equal to 9. Unfortunately, there is an insufficient amount of candy to satisfy all children. Therefore, the candies should be distributed in such a way that the sum of the children’s anger is minimal.

입력

The first line contains two integers, M (1 ≤ M ≤ 2·109) and N (1 ≤ N ≤ 100 000). The following N lines contain integers (one per line) which represent the wishes of the children. Those numbers are all strictly less than 2·109, and their sum always exceeds M.

출력

The first and only line of output must contain the minimum sum of the children’s anger. Note: The test cases will ensure that the result fits in a 64-bit unsigned integer: int64 in Pascal, long long in C/C++, long in Java.

예제 입력 1

5 3
1
3
2

예제 출력 1

1

예제 입력 2

10 4
4
5
2
3

예제 출력 2

4
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.