AtCoder Beginner Contest 156
翻译中…
Problem Statement
翻译中…
There are $N$ people living on a number line.
翻译中…
The $i$-th person lives at coordinate $X_i$.
翻译中…
You are going to hold a meeting that all $N$ people have to attend.
翻译中…
The meeting can be held at any integer coordinate. If you choose to hold the meeting at coordinate $P$, the $i$-th person will spend $(X_i - P)^2$ points of stamina to attend the meeting.
翻译中…
Find the minimum total points of stamina the $N$ people have to spend.
翻译中…
Constraints
翻译中…
- All values in input are integers.
$1 \leq N \leq 100$$1 \leq X_i \leq 100$
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
N
X_1 X_2 ... X_N
翻译中…
Output
翻译中…
Print the minimum total stamina the $N$ people have to spend.
翻译中…
样例
Input #1
2
1 4
Output #1
5
Assume the meeting is held at coordinate $2$. In this case, the first person will spend $(1 - 2)^2$ points of stamina, and the second person will spend $(4 - 2)^2 = 4$ points of stamina, for a total of $5$ points of stamina. This is the minimum total stamina that the $2$ people have to spend.
Note that you can hold the meeting only at an integer coordinate.
Input #2
7
14 14 2 13 56 2 37
Output #2
2354
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。