Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal integers by transforming some of them.
He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See Sample 2).
Find the minimum total cost to achieve his objective.

-----Constraints-----
 - 1≦N≦100
 - -100≦a_i≦100

-----Input-----
The input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N

-----Output-----
Print the minimum total cost to achieve Evi's objective.

-----Sample Input-----
2
4 8

-----Sample Output-----
8

Transforming the both into 6s will cost (4-6)^2+(8-6)^2=8 dollars, which is the minimum.
[{"code": "n = int(input())\na = list(map(int, input().split()))\n\nans = 1e9\nfor p in range(-100, 101):\n  sub = 0\n  for q in a:\n    sub += pow(p - q, 2)\n  ans = min(ans, sub)\n\nprint(ans)\n", "passed": true, "time": 0.28, "memory": 14128.0, "status": "done"}, {"code": "n = int(input())\na = [int(x) for x in input().split()]\nres = 10 ** 9\n\nfor i in range(-100,101):\n  cc = 0\n  for j in range(n):\n    cc += (i - a[j]) ** 2\n  res = min(res,cc)\n\nprint(res)", "passed": true, "time": 0.14, "memory": 14224.0, "status": "done"}, {"code": "N = int(input())\na = list(map(int, input().split()))\navg = round(sum(a)/N)\nsums = []\nfor i in range(min(a), avg+1):\n    s = 0\n    for j in range(N):\n        s += (i-a[j])**2\n    sums.append(s)\nprint(min(sums))", "passed": true, "time": 0.46, "memory": 14232.0, "status": "done"}, {"code": "from typing import List\n\n\ndef answer(n: int, a: List[int]) -> int:\n    cost = 0\n    num = round(sum(a) / n)\n    for i in a:\n        cost += (i - num) ** 2\n\n    return cost\n\n\ndef main():\n    n = int(input())\n    a = list(map(int, input().split()))\n    print(answer(n, a))\n\n\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.42, "memory": 15184.0, "status": "done"}, {"code": "import math\nfrom statistics import mean\n\nn = int(input())\na = list(map(int, input().split()))\n\nm = mean(a)\nif m - math.floor(m) < 0.5:\n    m = math.floor(m)\nelse:\n    m = math.floor(m) + 1\n\ndiff = 0\nfor v in a:\n    diff += (m - v) ** 2\n\nprint(diff)\n", "passed": true, "time": 0.38, "memory": 14120.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int,input().split()))\n\na_u = round(sum(a)/n)\na_d = int(sum(a)/n)\nans_u = 0\nans_d = 0\nfor i in range(n):\n    ans_u += (a[i]-a_u)**2\n    ans_d += (a[i]-a_d)**2\nprint((min(ans_u,ans_d)))\n#print(round(-2.5),int(-2.5))\n", "passed": true, "time": 0.38, "memory": 14120.0, "status": "done"}, {"code": "import math\nn = int(input())\na = list(map(int,input().split()))\navg = sum(a)/n\nx = math.floor(avg)\ny = math.ceil(avg)\nsumx = 0\nsumy = 0\nfor i in a:\n    sumx += (i - x) ** 2\n    sumy += (i - y) ** 2\n\nprint(min([sumx,sumy]))", "passed": true, "time": 0.56, "memory": 14328.0, "status": "done"}, {"code": "N=int(input())\n*A,=list(map(int,input().split()))\n\nmx=max(A)\nmn=min(A)\n\n\nif len(set(A))==1:\n    print((0))\nelse:\n    ans=float('inf')\n    for i in range(mn,mx):\n        ans=min(ans, sum([(k-i)**2 for k in A]))\n    print(ans)\n", "passed": true, "time": 0.46, "memory": 14200.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\n\nt = 10**9\nfor i in range(min(a),max(a)+1):\n    num = 0\n    for h in a:\n        num += (h-i)**2\n    if num <= t:\n        t = num\nprint(t)", "passed": true, "time": 0.14, "memory": 14088.0, "status": "done"}, {"code": "s=input();a=list(map(int,input().split()));ans=0\nmean=round(sum(a)/len(a))\n\nfor i in a:\n  p=(i-mean)**2\n  ans+=p\n  \nprint(ans)", "passed": true, "time": 0.32, "memory": 14236.0, "status": "done"}, {"code": "n=int(input())\nA=list(map(int,input().split()))\nans = [0]*201\nfor a in A:\n  for i in range(-100,101):\n    ans[i+100] += (a-i)**2\nprint(min(ans))", "passed": true, "time": 0.27, "memory": 14144.0, "status": "done"}, {"code": "maxa=(10)**11\nN=int(input())\nL=list(map(int,input().split()))\nfor i in range(-100,101):\n  R=[(i-y)**2 for y in L]\n  a=sum(R)\n  maxa=min(maxa,a)\nprint(maxa)", "passed": true, "time": 0.14, "memory": 14084.0, "status": "done"}, {"code": "N=int(input())\nList = list(map(int, input().split()))\nsumS = 0\nfor i in range(N):\n  sumS +=List[i]\ntrial = sumS // N\nmid = 0\nres = 10000000\nfor i in range(N):\n  trial += i\n  mid = 0 \n  for j in range(N):\n    mid += (trial - List[j])**2\n  res = min(res, mid)\nprint(res)", "passed": true, "time": 0.15, "memory": 14140.0, "status": "done"}, {"code": "num = int(input())\nstr_line = input().split(\" \")\nnum_line = [int(n) for n in str_line]\n\nave = 0\nfor i in range(num):\n    ave += num_line[i]\n\nif ave%num == 0:\n    ave //= num\n\nelse:\n    if ave%num <= num/2:\n        ave //= num\n    else:\n        ave = -(-ave//num)\n\nwa = 0\nfor i in range(num):\n    temp = num_line[i] - ave\n    wa += temp*temp\n    \nprint(wa)", "passed": true, "time": 0.14, "memory": 14080.0, "status": "done"}, {"code": "def main():\n    n = int(input())\n    al = list(map(int, input().split()))\n    maxval = max(abs(max(al)), abs(min(al)))\n    cost = []\n    if len(list(set(al))) == 1 :\n        print(\"0\")\n    else :\n        k = -1\n        for i in range(-100,100) :\n            k += 1\n            cost.append(0)\n            for j in range(n) :\n                cost[k] = cost[k] + (al[j] - i) ** 2\n                #print(cost[i])\n        print((min(cost)))\n\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14172.0, "status": "done"}, {"code": "import statistics\nimport math\nn = int(input())\na = list(map(int,input().split()))\nans1,ans2 = 0,0\na_avr1 = math.ceil((statistics.mean(a)))\na_avr2 = math.floor((statistics.mean(a)))\nfor i in range(n):\n  ans1 += (a[i] - a_avr1)**2\n  ans2 += (a[i] - a_avr2)**2\nprint(min(ans1,ans2))", "passed": true, "time": 0.15, "memory": 14136.0, "status": "done"}, {"code": "n=int(input())\na=[int(i) for i in input().split()]\n\nans=10000000000000000\nfor criterion in range(-100,101):\n    result=0\n    for i in a:\n        result+=(i-criterion)**2\n    ans=min(ans,result)\nprint(ans)", "passed": true, "time": 0.14, "memory": 14308.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\navg_a = round(sum(a)/n)\n\nresult = 0\nfor num in a:\n    result += (num-avg_a)**2\n\nprint(result)", "passed": true, "time": 0.14, "memory": 14232.0, "status": "done"}, {"code": "n = int(input())\na_list = list(map(int,input().split()))\nmid = round(sum(a_list)/n)\nans = 0\nfor a in a_list:\n    ans += (a-mid) ** 2\nprint(ans)", "passed": true, "time": 0.14, "memory": 14316.0, "status": "done"}, {"code": "n = int(input())\na = [int(x) for x in input().split()]\na.sort()\nans = []\nfor i in range(a[0], a[-1]+1):\n    cnt = 0\n    for j in range(n):\n        cnt += (a[j] - i)**2\n    ans.append(cnt)\n\nprint(min(ans))", "passed": true, "time": 0.14, "memory": 14092.0, "status": "done"}, {"code": "N = int(input())\na = list(map(int, input().split()))\n\nmy_round_int = lambda x: int((x * 2 + 1) // 2)\nm = my_round_int(sum(a)/len(a))\n\ncost = 0\n\nfor i in a:\n    cost += (i - m)**2\n\nprint(cost)", "passed": true, "time": 0.14, "memory": 14076.0, "status": "done"}, {"code": "N = int(input())\na = list(map(int, input().split()))\nb = []\nfor i in range(-100, 101):\n\tt = 0\n\tfor j in a:\n\t\tt += (j - i) ** 2\n\tb.append(t)\nprint(min(b))", "passed": true, "time": 0.14, "memory": 14136.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int,input().split()))\n\nmin_a = min(A)\nmax_a = max(A)\n\nans = float(\"inf\")\nfor i in range(min_a, max_a+1):\n  tmp = 0\n  for j in A:\n    tmp += (i - j) ** 2\n  ans = min(ans, tmp)\n  \nprint(ans)", "passed": true, "time": 0.14, "memory": 14108.0, "status": "done"}, {"code": "n = int(input())\na = [ int(x) for x in input().split() ]\n\navg = round(sum(a) / n)\n\ncost = 0\n\nfor e in a:\n    cost += (e-avg)**2\n\nprint(cost)\n", "passed": true, "time": 0.23, "memory": 14264.0, "status": "done"}, {"code": "n = int(input())\nlst = list(map(int, input().split()))\nm = 10 ** 10\nfor i in range(201):\n  a = i - 100\n  temp = 0\n  for j in range(n):\n    temp += ((lst[j] - a) ** 2)\n  m = min(m, temp)\nprint(m)", "passed": true, "time": 0.14, "memory": 14084.0, "status": "done"}, {"code": "N = int(input())\na = list(map(int, input().split()))\nmi = min(a)\nma = max(a)\n\nans = float('inf')\nfor i in range(mi, ma + 1):\n    ans = min(ans, sum((i - ai) ** 2 for ai in a))\n\nprint(ans)", "passed": true, "time": 0.14, "memory": 14212.0, "status": "done"}, {"code": "def cost(x):\n    cost = (x - ave)**2\n    return cost\n\n\nn = input()\na = list(map(int, input().split()))\nave = round(sum(a)/int(n))\nprint(sum(list(map(cost, a))))", "passed": true, "time": 0.14, "memory": 14196.0, "status": "done"}, {"code": "n = int(input())\nA = list(map(int, input().split()))\n\nans = float('inf')\nfor x in range(-100, 101, 1):\n    c = 0\n    for a in A:\n        c += (a - x) ** 2\n    ans = min(c, ans)\nprint(ans)", "passed": true, "time": 0.14, "memory": 14264.0, "status": "done"}, {"code": "N=int(input())\nn=list(map(int, input().split()))\nm=int(sum(n)/N)\n\ndef fun(x):\n  ans=0\n  for i in n:\n    ans+=(i-x)**2\n  return(ans)\n  \np=fun(m)\nq=fun(m+1)\nif p<q:\n  print(p)\nelse:\n  print(q)", "passed": true, "time": 0.14, "memory": 14100.0, "status": "done"}, {"code": "n = int(input())\na = [int(x) for x in input().split()]\nA = min(a)\nB = max(a)\ntemp = 10000000000000000000000\nfor i in range(A,B+1):\n    ans = 0\n    for j in a:\n        ans+= (abs(j-i))**2\n    #print(ans)\n    temp = min(temp,ans)\nprint(temp)\n", "passed": true, "time": 0.14, "memory": 14240.0, "status": "done"}, {"code": "n=int(input())\na=[int(i)for i in input().split()]\ncost=[]\nfor i in range(-100,101):\n    tmp=0\n    for j in a:\n        tmp+=(j-i)**2\n    cost.append(tmp)\nprint(min(cost))", "passed": true, "time": 0.14, "memory": 14184.0, "status": "done"}, {"code": "n = float(input())\n\na = list(map(int,input().split()))\n\nave = round(sum(a)/n)\n\nprint(sum(list(map(lambda x:(x-ave)**2,a))))", "passed": true, "time": 0.16, "memory": 14356.0, "status": "done"}, {"code": "n = int(input())\na_list = list(map(int,input().split()))\nmid = round(sum(a_list)/n)\nans = 0\nfor a in a_list:\n    ans += (a-mid) ** 2\nprint(ans)", "passed": true, "time": 0.71, "memory": 14108.0, "status": "done"}, {"code": "N=int(input())\nn=list(map(int, input().split()))\nm=int(sum(n)/N)\n \ndef fun(x):\n  ans=0\n  for i in n:\n    ans+=(i-x)**2\n  return(ans)\n  \ns=min(fun(m),fun(m+1))\nprint(s)", "passed": true, "time": 0.71, "memory": 14072.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int,input().split()))\ncosts = []\n\nfor i in range(101):\n  cost = 0\n  for j in range(N):\n    cost += (A[j]-i)**2\n  costs.append(cost)\n  cost = 0\n  for j in range(N):\n    cost += (A[j]+i)**2\n  costs.append(cost)\n\nprint(min(costs))", "passed": true, "time": 0.24, "memory": 14088.0, "status": "done"}, {"code": "N = int(input())\na = list(map(int, input().split()))\ns = sum(a)\nx = int(s / len(a))\n\nif (x + 1) - (s / len(a)) < (s / len(a)) - x:\n    x += 1\ncost = 0\nfor y in a:\n    cost += pow(y - x, 2)\n\nprint(cost)", "passed": true, "time": 0.24, "memory": 14340.0, "status": "done"}, {"code": "import math\nfrom datetime import date\n\ndef f(x, a):\n\tans = 0\n\tfor y in a:\n\t\tans += (x - y) ** 2\n\n\treturn ans\n\ndef main():\n\t\n\tn = int(input())\n\ta = [int(x) for x in input().split()]\n\ts = 0\n\tfor x in a:\n\t\ts += x\n\n\ts = s // n\n\tans = 10**17\n\n\tfor x in range(s - 2, s + 3):\n\t\tans = min(ans, f(x, a))\n\n\tprint(ans)\n\t\nmain()\n", "passed": true, "time": 0.23, "memory": 16528.0, "status": "done"}, {"code": "n=int(input())\na=list(map(int, input().split()))\n\nresult = 10**9\nfor num in range(-100,101):\n  cost = 0\n  for i in range(n):\n    cost += (a[i] - num) ** 2\n  result = min(result, cost)\nprint(result)", "passed": true, "time": 0.15, "memory": 14304.0, "status": "done"}, {"code": "\nN = int(input())\nlist = [int(a) for a in input().split()]\n\nA = sum(list)//N\nans = 0\n\nfor k in range(N):\n    ans = ans + (list[k] - A) ** 2\n\nfor i in range(-100,100):\n    sum_new = 0\n    for j in range(N):\n        sum_new = sum_new + (list[j] - i) ** 2\n    if(ans > sum_new):\n        ans = sum_new\n\nprint(ans)\n", "passed": true, "time": 0.15, "memory": 14204.0, "status": "done"}, {"code": "N=int(input())\na=sorted(list(map(int,input().split())))\n\nans=10**9\nfor i in range(a[0],a[-1]+1):\n  s=0\n  for j in range(N):\n    x=(a[j]-i)**2\n    s+=x\n  ans=min(ans,s)\n\nprint(ans)\n", "passed": true, "time": 0.15, "memory": 14104.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int,input().split()))\nb = 0\n\nfor i in range(n):\n    b += a[i]\n\nc = int(b/n)\nd = c + 1\ne = 0\nf = 0\n\nfor i in range(n):\n    e += (a[i]-c)**2\n    f += (a[i]-d)**2\n\nprint((min(e,f)))\n\n", "passed": true, "time": 0.15, "memory": 14316.0, "status": "done"}, {"code": "N = int(input())\nint_list = [int(x) for x in input().split()]\n\n# int_list\u306e\u5404\u6574\u6570\u3092y\u306b\u66f8\u304d\u63db\u3048\u308b\u3068\u304d\u306e\u30b3\u30b9\u30c8\u306e\u7dcf\u548c\u3092\u8a08\u7b97\ndef calc_cost(int_list, y):\n    cost = 0\n    for x in int_list:\n        cost += (x - y)**2\n    return cost\n\ncost_list = [calc_cost(int_list, y) for y in range(min(int_list), max(int_list)+1)]\nprint(min(cost_list))", "passed": true, "time": 0.22, "memory": 14072.0, "status": "done"}, {"code": "N=int(input())\na=list(map(int,input().split()))\n\nA=sum(a)//N\nB=(sum(a)-1)//N+1\n\n\nprint((min(sum((x-A)*(x-A) for x in a),sum((x-B)*(x-B) for x in a))))\n", "passed": true, "time": 0.21, "memory": 14080.0, "status": "done"}, {"code": "input();a=list(map(int,input().split()));r=float('inf')\nfor i in range(min(a),max(a)+1):\n  n=0\n  for j in a:\n    n+=(j-i)**2\n  r=min(n,r)\nprint(r)", "passed": true, "time": 0.28, "memory": 14328.0, "status": "done"}, {"code": "#!/usr/bin/env python3\nimport sys\n\n\ndef solve(N: int, a: \"List[int]\"):\n    ans = float(\"inf\")\n    for m in range(-100, 101):\n        ans = min(ans,\n                  sum((aa-m)**2 for aa in a))\n    return ans\n\n\n# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools\ndef main():\n    def iterate_tokens():\n        for line in sys.stdin:\n            for word in line.split():\n                yield word\n    tokens = iterate_tokens()\n    N = int(next(tokens))  # type: int\n    a = [int(next(tokens)) for _ in range(N)]  # type: \"List[int]\"\n    print((solve(N, a)))\n\ndef test():\n    import doctest\n    doctest.testmod()\n\ndef __starting_point():\n    #test()\n    main()\n\n__starting_point()", "passed": true, "time": 0.15, "memory": 14352.0, "status": "done"}, {"code": "import sys\n\nsys.setrecursionlimit(10 ** 8)\nini = lambda: int(sys.stdin.readline())\ninl = lambda: [int(x) for x in sys.stdin.readline().split()]\nins = lambda: sys.stdin.readline().rstrip()\ndebug = lambda *a, **kw: print(\"\\033[33m\", *a, \"\\033[0m\", **dict(file=sys.stderr, **kw))\n\n\ndef solve():\n    n = ini()\n    a = inl()\n    s = sum(a)\n    m1 = s // n\n    m2 = (s + n - 1) // n\n\n    s1 = sum((x - m1) ** 2 for x in a)\n    s2 = sum((x - m2) ** 2 for x in a)\n    return min(s1, s2)\n\n\nprint(solve())\n", "passed": true, "time": 0.15, "memory": 14212.0, "status": "done"}, {"code": "import sys\nimport math\n\nN = int(input())\n\na = list(map(int, input().split()))\n\na.sort()\nans = 10**9\nfor i in range(a[0], a[-1]+1):\n    cost = 0\n    for j in a:\n        cost += (i-j)**2\n    ans = min(cost, ans)\nprint(ans)", "passed": true, "time": 0.15, "memory": 14132.0, "status": "done"}, {"code": "inf = float('inf')\nn = int(input())\narr = list(map(int, input().split()))\n\nmin_cost = inf\nfor i in range(-100, 101):\n    cost = 0\n    for j in arr:\n        cost += (j - i)**2\n    min_cost = min(min_cost, cost)\nprint(min_cost)", "passed": true, "time": 0.14, "memory": 14328.0, "status": "done"}, {"code": "n=int(input())\na=list(map(int,input().split()))\n\ninf=float('inf')\n\nans=inf\n\nfor b in range(-100,101):\n  ch=0\n  for i in range(n):\n    ch+=(b-a[i])**2\n    \n  ans=min(ans,ch)\n  \nprint(ans)", "passed": true, "time": 0.16, "memory": 14276.0, "status": "done"}, {"code": "n=int(input())\na=list(map(int,input().split()))\n# n=2\n# a=[4,8]\nminimum=10000000\nfor i in range(-100,101):\n    cost=0\n    for j in range(n):\n        cost+=(i-(a[j]))**2\n        if j==n-1:\n            if cost<minimum:\n                minimum=cost\n\nprint(minimum)\n\n\n", "passed": true, "time": 0.15, "memory": 14068.0, "status": "done"}, {"code": "from sys import stdin\ninput = stdin.readline\n\nN = int(input())\nA = list(map(int, input().split()))\n\nif len(set(A)) != 1:\n    cost = 2**20\n    for i in range(-100, 101):\n        tc = 0\n        for a in A:\n            tc += (a-i)**2\n        if cost > tc:\n            cost = tc\nelse:\n    cost = 0\n\nprint(cost)", "passed": true, "time": 0.14, "memory": 14368.0, "status": "done"}, {"code": "N = int(input())\nl = list(map(int, input().split()))\ncal = []\nfor i in range(-100,101):\n    a = 0\n    for j in l:\n        a += (i - j)**2\n    cal.append(a)\n\nans = min(cal)\nprint(ans)", "passed": true, "time": 0.14, "memory": 14188.0, "status": "done"}, {"code": "n = int(input())\narr = list(map(int, input().split()))\n\nmini = min(arr)\nmaxi = max(arr)\ncost = 10000000000\n\nfor i in range(-100, 101+1):\n    add = 0\n    for j in range(n):\n        add = add + (arr[j] - i)**2\n    cost = min(cost, add)\nprint(cost)", "passed": true, "time": 0.14, "memory": 14332.0, "status": "done"}, {"code": "def sam(lst):\n  return lst[1:] == lst[:-1]\n\nn = int(input())\ns = [int(x) for x in input().split()]\nif(sam(s)):\n  print(0)\nelse:\n  x = round(sum(s)/n)\n  n = 0\n  for elem in s:\n    n += (elem-x)**2\n  print(n)", "passed": true, "time": 0.14, "memory": 14304.0, "status": "done"}, {"code": "N = int(input())\nnum_list = list(map(int, input().split()))\ncost_list = []\nmax_num = max(num_list)\nmin_num = min(num_list)\n\nfor i in range(min_num,max_num):\n    cost = 0\n    for j in num_list:\n        cost += (i-j)**2\n    cost_list.append(cost)\n\nif len(cost_list) == 0:\n    cost_list.append(0)\n    \nprint(min(cost_list))", "passed": true, "time": 0.15, "memory": 14092.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int, input().split()))\n\nmin_cost = 10 ** 9 + 7\nfor i in range(-100, 101):\n    cost = 0\n    for j in range(N):\n        cost += (A[j] - i) ** 2\n    min_cost = min(cost, min_cost)\n\nprint(min_cost)\n", "passed": true, "time": 0.14, "memory": 14284.0, "status": "done"}, {"code": "N = input()\nlist1 = list(map(int,input().split()))\nlist2 = []\nfor i in range(min(list1),max(list1)+1):\n    a = 0\n    for j in range(len(list1)):\n        a += (list1[j] - i)**2\n    list2.append(a)\nprint(min(list2))", "passed": true, "time": 0.14, "memory": 14156.0, "status": "done"}, {"code": "n=int(input())\na=list(map(int, input().split()))\na.sort()\nans=10**10\nfor x in range(a[0],a[-1]+1):\n    tmp=0\n    for i in range(n):\n        tmp+=(a[i]-x)**2\n    ans=min(ans,tmp)\nprint(ans)", "passed": true, "time": 0.14, "memory": 14228.0, "status": "done"}, {"code": "import math\nimport statistics\nN = int(input())\nA = [int(x) for x in input().split()]\navg = math.floor(statistics.mean(A))\na = 0\nb = 0\nfor i in range(len(A)):\n    a += (A[i] - avg)**2\n    b += (A[i] - avg - 1)**2\nprint(min(a,b))", "passed": true, "time": 0.15, "memory": 14096.0, "status": "done"}, {"code": "N=input()\n*A,=map(int,input().split())\n\na=float('inf')\nfor i in range(min(A),max(A)+1):a=min(a, sum([(k-i)**2 for k in A]))\nprint(a)", "passed": true, "time": 0.72, "memory": 14116.0, "status": "done"}, {"code": "n=int(input())\nl=list(map(int,input().split()))\nans=float('inf')\nfor v in range(min(l),max(l)+1):\n    c=sum([(a-v)**2 for a in l])\n    ans=min(ans,c)\nprint(ans)\n", "passed": true, "time": 0.25, "memory": 14196.0, "status": "done"}, {"code": "N = int(input())\nL = list(map(int, input().split()))[:N]\n\nstart = round(sum(L) / N)\nf = lambda x: (x - start)**2\n\nprint(sum(list(map(f, L))))", "passed": true, "time": 0.19, "memory": 14208.0, "status": "done"}, {"code": "N=int(input())\ns=list(map(int,input().split()))\ns_max=max(s)\ns_min=min(s)\nA=[]\nfor i in range(s_min,s_max+1):\n  b=0\n  for j in s:\n    b+=(j-i)**2\n  A.append(b)\nprint(min(A))", "passed": true, "time": 0.18, "memory": 14208.0, "status": "done"}, {"code": "N=int(input())\na=list(map(int,input().split()))\n\ndef calc_cost(x,avg):\n  return (x-avg)**2\n\navg = sum(a)//N\n\ndelta = [-2,-1,0,1,2]\n\nans=10**20\nfor i in range(len(delta)):\n  val = sum(map(lambda x:calc_cost(x,avg+delta[i]),a))\n  ans = min(ans,val)\n  \nprint(ans)", "passed": true, "time": 0.2, "memory": 14228.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\nans = 10**10\nfor i in range(min(a), max(a)+1):\n    cnt = 0\n    for j in range(n):\n        cnt += (a[j]-i) ** 2\n    ans = min(ans, cnt)\nprint(ans)", "passed": true, "time": 0.15, "memory": 14260.0, "status": "done"}, {"code": "N=int(input())\nA=[int(x) for x in input().split()]\nmaxA=max(A)\nminA=min(A)\nans=10**9\nfor i in range(minA,maxA+1):\n    kouho=0\n    for j in range(N):\n        kouho+=(i-A[j])**2\n    ans=min(ans,kouho)\nprint(ans)", "passed": true, "time": 0.14, "memory": 14292.0, "status": "done"}, {"code": "n=int(input())\na=list(map(int,input().split()))\nans=100000000\nfor i in range(-100,101):\n    now=0\n    for k in a:\n        now+=(i-k)*(i-k)\n    ans=min(ans,now)\nprint(ans)", "passed": true, "time": 0.15, "memory": 14136.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\n\nans = 10**9\nfor i in range(-100, 101):\n    cost = 0\n    for j in a:\n        cost += (j-i)**2\n    ans = min(ans, cost)\nprint(ans)", "passed": true, "time": 0.23, "memory": 14220.0, "status": "done"}, {"code": "N = int(input())\nA = [int(T) for T in input().split()]\nMin = 10**9\nfor TN in range(min(A),max(A)+1):\n    Min = min(Min,sum((TN-TA)**2 for TA in A))\nprint(Min)", "passed": true, "time": 0.24, "memory": 14276.0, "status": "done"}, {"code": "ans=10**10\nn=int(input())\na=list(map(int,input().split()))\nfor i in range(-100,101):\n  x=0\n  for j in range(n):\n    x+=(i-a[j])**2\n  ans=min(x,ans)\nprint(ans)", "passed": true, "time": 0.23, "memory": 14176.0, "status": "done"}, {"code": "N=int(input())\n*A,=map(int,input().split())\n\nmx=max(A)\nmn=min(A)\n\nans=float('inf')\nfor i in range(mn,mx+1):\n    ans=min(ans, sum([(k-i)**2 for k in A]))\nprint(ans)", "passed": true, "time": 0.15, "memory": 14116.0, "status": "done"}, {"code": "import sys\nimport math\n\ndef main():\n\n    input()\n    a = list(map(int, input().split()))\n\n    y = round(sum(a)/len(a))\n\n    ans = 0\n    for i in a:\n        ans += pow((i - y), 2)\n\n    print(ans)\n\n\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.15, "memory": 14268.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int, input().split()))\nans = 0\n\nif sum(A)%N == 0:\n    x = sum(A)//N\n    for i in range(N):\n        ans += (x-A[i])**2\n    print(ans)\nelse:\n    x = sum(A)//N\n    b = sum(A)//N+1\n    if sum(A)/N - x > b - sum(A)/N:\n        x = b\n    for i in range(N):\n        ans += (x-A[i])**2\n    \n    print(ans)\n\n", "passed": true, "time": 0.16, "memory": 14324.0, "status": "done"}, {"code": "def main():\n    n = int(input())\n    As = list(map(int, input().split()))\n    ans = float(\"inf\")\n\n    for i in range(-100, 101):\n        ans_temp = 0\n        for j in range(n):\n            ans_temp += (As[j] + i)**2\n        ans = min(ans, ans_temp)\n    print(ans)\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14104.0, "status": "done"}, {"code": "import math\n \nN = int(input())\nA = [int(a) for a in input().split(\" \")]\nave = sum(A) / N\ncan1 = math.floor(ave)\ncan2 = math.ceil(ave)\n \ncost1 = sum([(a - can1) ** 2 for a in A])\ncost2 = sum([(a - can2) ** 2 for a in A])\nprint(min([cost1, cost2]))", "passed": true, "time": 0.14, "memory": 14128.0, "status": "done"}, {"code": "N = int(input())\nlst = list(map(int, input().split()))\navg = round(sum(lst) / N)\n\nresult = 0\nfor i in lst:\n    result += (i - avg)**2\n\nprint(result)\n", "passed": true, "time": 0.14, "memory": 14136.0, "status": "done"}, {"code": "N = int(input())\na = list(map(int,input().split()))\nb = 0\nfor i in range(N):\n    b += a[i]\nr = round(b/N)\nans = 0\nfor i in range(N):\n    ans += (a[i]-r)**2\nprint(ans)", "passed": true, "time": 0.14, "memory": 14112.0, "status": "done"}, {"code": "# C - \u3044\u3063\u3057\u3087\ndef main():\n    import math\n    _ = int(input())\n    a = list(map(int, input().split()))\n    t = float('inf')\n\n    for i in range(min(a), max(a)+1):\n        cnt = 0\n        for j in a:\n            cnt += (j-i)**2\n        else:\n            if cnt < t:\n                t = cnt\n    else:\n        print(t)\n\n    \nif __name__ ==  \"__main__\":\n    main()", "passed": true, "time": 0.14, "memory": 14252.0, "status": "done"}, {"code": "def keisan(N,A):\n     \n     KAI = 0\n     A.sort\n \n     min = -100\n     max = 101\n     \n     i = min\n     \n     while i <= max:\n         kari = 0\n         j = 0\n         while j < N:\n             kari += (A[j]-i)**2\n             j += 1\n        \n         \n         if kari <= KAI or i == min:\n             KAI = kari\n         i += 1\n \n     \n     return KAI\n \n \nN = int(input())\n \nA = input().split()\nint_list = list(map(int,A))\n \nprint(keisan(N,int_list))", "passed": true, "time": 0.14, "memory": 14128.0, "status": "done"}, {"code": "n = int(input())\na_list = [int(x) for x in input().split()]\n\na_sum = sum(a_list)\nf = a_sum // n\nc = (a_sum + n - 1) // n\nb = f if abs(a_sum - f * n) < abs(a_sum - c * n) else c\n\nans = 0\nfor a in a_list:\n    ans += (a - b) ** 2\nprint(ans)", "passed": true, "time": 0.14, "memory": 14020.0, "status": "done"}, {"code": "n = int(input())\nl = list(input().split())\nsum = 0\nmin_sum = 10**10\nnum = 0\nfor i in range(-100,101):\n    for j in range(len(l)):\n        sum += (int(l[j]) - i)**2\n    if min_sum > sum:\n        min_sum = sum\n        num = i\n    sum = 0\n\nprint(min_sum)", "passed": true, "time": 0.16, "memory": 14148.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\nm1 = sum(a) // n\nm2 = (sum(a) + n - 1) // n\n\nres1 = 0\nres2 = 0\nfor i in range(n):\n    res1 += (a[i] - m1) ** 2\n    res2 += (a[i] - m2) ** 2\n\nprint((min(res1, res2)))\n", "passed": true, "time": 0.14, "memory": 14284.0, "status": "done"}, {"code": "\nclass Combination:\n    def __init__(self, n, mod):\n        self.n = n\n        self.mod = mod\n        self.fac = [1 for i in range(self.n + 1)]\n        self.finv = [1 for i in range(self.n + 1)]\n        for i in range(2, self.n+1):\n            self.fac[i] = (self.fac[i - 1] * i) % self.mod\n            self.finv[i] = (self.finv[i-1] * pow(i, -1, self.mod)) % self.mod\n\n    def comb(self, n, m):\n        return self.fac[n] * (self.finv[n-m] * self.finv[m] % self.mod) % self.mod\ndef iparse():\n    return list(map(int, input().split()))\n\ndef __starting_point():\n    n = int(input())\n    a = iparse()\n    ans = 10000000000\n    for i in range(-100, 101):\n        tmp = 0\n        for e in a:\n            tmp += (e - i)** 2\n        ans = min(tmp, ans)\n    print(ans)\n    \n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14268.0, "status": "done"}, {"code": "def main():\n    n = int(input())\n    a_lst = list(map(int, input().split()))\n    minimum = min(a_lst)\n    maximum = max(a_lst)\n\n    cost = 10 ** 9\n    for i in range(maximum - minimum + 1):\n        tmp_cost = 0\n        std = minimum + i\n        for j in range(n):\n            a = a_lst[j]\n            tmp_cost += (a - std) ** 2\n        cost = min(tmp_cost, cost)\n\n    print(cost)\n\n\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.14, "memory": 14232.0, "status": "done"}, {"code": "def main():\n    n = int(input())\n    inlis = list(map(int, input().split()))\n\n    ans = 10 ** 10\n\n    for kouho1 in range(-100,101):\n        tmp1 = 0\n        for i in range(n):\n            tmp1 += (inlis[i]- kouho1) ** 2\n        if tmp1 < ans:\n            ans = tmp1\n    print(ans)\n\n\n\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.14, "memory": 14176.0, "status": "done"}, {"code": "N = int(input())\nl = list(map(int,input().split()))\nl_ans = [[] for _ in range(201)]\n\nfor i in range(-100,101):\n    sum = 0\n\n    for j in range(N):\n        sum = sum + (i-l[j])**2\n\n    l_ans[i+100] = sum\n\nprint(min(l_ans))", "passed": true, "time": 0.14, "memory": 14212.0, "status": "done"}, {"code": "n = int(input())\nA = list(map(int,input().split()))\nans = 10**9\nfor i in range(-100,101):\n  tmp = 0\n  for a in A:\n    tmp += (a-i)**2\n  ans = min(ans, tmp)\nprint(ans)", "passed": true, "time": 0.22, "memory": 14344.0, "status": "done"}, {"code": "N = int(input())\na = list(map(int,input().split()))\n\navg = round((sum(a) / N))\nans = 0\nfor i in a:\n  ans = ans + (i-avg) * (i-avg)\n\nprint(ans)", "passed": true, "time": 0.14, "memory": 14304.0, "status": "done"}, {"code": "n = int(input())\nnums = list(map(int, input().split()))\n\ndef cost(x,y):\n    return (x-y)**2\n\navg = round(sum(nums)/len(nums))\n\nres = 0\nfor n in nums:\n    res += cost(n, avg)\nprint(res)\n", "passed": true, "time": 0.15, "memory": 14104.0, "status": "done"}, {"code": "n=int(input())\na = list(map(int,input().split()))\n_sum =sum(a) / n\ns  = round(_sum)\nans = 0\n#print(s)\nfor i in range(n):\n    v =(a[i]-s)**2\n    ans += v\nprint(ans)", "passed": true, "time": 0.14, "memory": 14220.0, "status": "done"}, {"code": "N = int(input())\nA = [int(x) for x in input().split()]\nfrom statistics import mean\nfrom math import floor, ceil\nmeanA = mean(A)\nif meanA < floor(meanA) + 0.5:\n    meanA = floor(meanA)\nelse:\n    meanA = ceil(meanA)\nans = 0\nfor a in A:\n    ans += (a-meanA)**2\nprint(ans)", "passed": true, "time": 0.15, "memory": 14192.0, "status": "done"}, {"code": "n = input()\na = list(map(int, input().split()))\nans = list()\nfor i in range(min(a), max(a)+1):\n    cost = 0\n    for num in a:\n        cost += (num - i)**2\n    ans.append(cost)\nprint(min(ans))", "passed": true, "time": 0.14, "memory": 14172.0, "status": "done"}, {"code": "N=int(input())\na=list(map(int,input().split()))\nave=sum(a)/N\nif ave>=0 and ave%1>=0.5:\n    ave=int(ave)+1\nelif ave<0 and -ave%1>=0.5:\n    ave=int(ave)-1\nelse:\n    ave=int(ave)\nans=0\nfor i in a:\n    ans+=(i-ave)**2\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14100.0, "status": "done"}, {"code": "# N\u306e\u5165\u529b\u53d7\u4ed8\nN = int(input())\n# a\u306e\u5165\u529b\u53d7\u4ed8\naN = list(map(int, input().split()))\n# \u5e73\u5747\u306e\u5024\u3092\u8a08\u7b97\nS = 0\nA = 0\nfor i in aN:\n    S += i\nA = S / N\nif A - int(A) < 0.5:\n    A = int(A)\nelse:\n    A = int(A) + 1\n# A\u306b\u3059\u3079\u3066\u66f8\u304d\u63db\u3048\u308b\u3068\u304d\u306e\u30b3\u30b9\u30c8\u3092\u8a08\u7b97\nR = 0\nfor i in aN:\n    R += (i - A)**2\nprint(R)\n", "passed": true, "time": 0.14, "memory": 14168.0, "status": "done"}, {"code": "#!/usr/bin/env python\n\nn = int(input())\na = list(map(int, input().split()))\n\nans = 1000100\nch = 0 \nfor ch in range(min(a), max(a)+1):\n    tmp = 0 \n    for i in range(n):\n        tmp += (a[i]-ch)**2\n    if tmp <= ans:\n        ans = tmp \nprint(ans)\n", "passed": true, "time": 0.15, "memory": 14336.0, "status": "done"}]