Buggy python submission (verdict: Runtime Error):

N = int(input())
list = [int(a) for a in input().split()]

A = sum(list)//N

for k in range(N):
    ans = (list[j] - A) ** 2

for i in range(-100,100):
    sum = 0
    sum_new = 0
    for j in range(N):
        sum = sum + (list[j] - A) ** 2
        sum_new = sum_new + (list[j] - i) ** 2
    if(sum > sum_new):
        ans = sum_new

print(ans)


Fixed submission:

N = int(input())
list = [int(a) for a in input().split()]

A = sum(list)//N
ans = 0

for k in range(N):
    ans = ans + (list[k] - A) ** 2

for i in range(-100,100):
    sum_new = 0
    for j in range(N):
        sum_new = sum_new + (list[j] - i) ** 2
    if(ans > sum_new):
        ans = sum_new

print(ans)

Buggy python submission (verdict: Runtime Error):

N = int(input())
list = [int(a) for a in input().split()]

A = sum(list)//N

for k in rang(N):
    ans = (list[j] - A) ** 2

for i in range(-100:100):
    for j in range(N):
        sum = 0
        sum_new = 0
        sum = sum + (list[j] - A) ** 2
        sum_new = sum_new + (list[j] - i) ** 2
    if(sum > sum_new):
        ans = sum_new

print(ans)


Fixed submission:

N = int(input())
list = [int(a) for a in input().split()]

A = sum(list)//N
ans = 0

for k in range(N):
    ans = ans + (list[k] - A) ** 2

for i in range(-100,100):
    sum_new = 0
    for j in range(N):
        sum_new = sum_new + (list[j] - i) ** 2
    if(ans > sum_new):
        ans = sum_new

print(ans)

Buggy python submission (verdict: Runtime Error):

N = int(input())
list = [int(a) for a in input().split()]

A = sum(list)//N

for i in range(-100:100):
    for j in range(N):
        sum = 0
        sum_new = 0
        sum = sum + (list[j] - A) ** 2
        sum_new = sum_new + (list[j] - i) ** 2
        if(sum > sum_new):
            sum = sum_new
print(sum)


Fixed submission:

N = int(input())
list = [int(a) for a in input().split()]

A = sum(list)//N
ans = 0

for k in range(N):
    ans = ans + (list[k] - A) ** 2

for i in range(-100,100):
    sum_new = 0
    for j in range(N):
        sum_new = sum_new + (list[j] - i) ** 2
    if(ans > sum_new):
        ans = sum_new

print(ans)

Buggy python submission (verdict: Runtime Error):

N = int(input())
list = [int(a) for a in input().split()]

A = sum(list)//N
sum = 0
sum_new = 0

for i in range(-100:100):
    for j in range(N):
        sum = sum + (list[j] - A) ** 2
        sum_new = sum_new + (list[j] - i) ** 2
        if(sum > sum_new):
            sum = sum_new
print(sum)


Fixed submission:

N = int(input())
list = [int(a) for a in input().split()]

A = sum(list)//N
ans = 0

for k in range(N):
    ans = ans + (list[k] - A) ** 2

for i in range(-100,100):
    sum_new = 0
    for j in range(N):
        sum_new = sum_new + (list[j] - i) ** 2
    if(ans > sum_new):
        ans = sum_new

print(ans)

Buggy python submission (verdict: Runtime Error):

N = int(input())
list = [int(a) for a in input().split()]

A = sum(list)//N
sum = 0
sum_new = 0

for i in range(-100:100):
    for j in range(N):
        sum = sum + (list[j] - A) ** 2
        sum_new = (list[j] - i) ** 2
        if(sum > sum_new):
            sum = sum_new
print(sum)


Fixed submission:

N = int(input())
list = [int(a) for a in input().split()]

A = sum(list)//N
ans = 0

for k in range(N):
    ans = ans + (list[k] - A) ** 2

for i in range(-100,100):
    sum_new = 0
    for j in range(N):
        sum_new = sum_new + (list[j] - i) ** 2
    if(ans > sum_new):
        ans = sum_new

print(ans)

Buggy python submission (verdict: Runtime Error):

N = int(input())
list = [int(a) for a in input().split()]

A = sum(list)//N



for i in range(-100:100):
    for j in range(N):    
        sum = (list[j] - A) ** 2
        sum_new = (list[j] - i) ** 2
    if(sum > sum_new):
        sum = sum_new
print(sum)


Fixed submission:

N = int(input())
list = [int(a) for a in input().split()]

A = sum(list)//N
ans = 0

for k in range(N):
    ans = ans + (list[k] - A) ** 2

for i in range(-100,100):
    sum_new = 0
    for j in range(N):
        sum_new = sum_new + (list[j] - i) ** 2
    if(ans > sum_new):
        ans = sum_new

print(ans)

Buggy python submission (verdict: Runtime Error):

N = int(input())
list = [int(a) for a in input().split()]

A = sum(list)//N

for i in range(-100:100):
    sum = (list[i] - A) ** 2
    sum_new = (list[i] - i) ** 2
    if(sum > sum_new):
        sum = sum_new
print(sum)


Fixed submission:

N = int(input())
list = [int(a) for a in input().split()]

A = sum(list)//N
ans = 0

for k in range(N):
    ans = ans + (list[k] - A) ** 2

for i in range(-100,100):
    sum_new = 0
    for j in range(N):
        sum_new = sum_new + (list[j] - i) ** 2
    if(ans > sum_new):
        ans = sum_new

print(ans)