n = int(eval(input()))

arr = list(map(int, input().split()))



dic = {}

for i in range(1,n+1):  

  S1 = sum(arr[:i])  

  S2 = sum(arr[i:])  

  dic[i] = abs(S1-S2)  

ans = sorted(list(dic.items()), key=lambda x:x[1])  



print((ans[0][1]))  

  
N = int(eval(input()))

A = list(map(int, input().split()))



ans = 1<<60

for t in range(1, N):

  L = sum(A[:t])  

  R = sum(A[t:])

  ans = min(ans, abs(L-R))

  

print(ans)  

  

  
n = int(eval(input()))
arr = list(map(int, input().split()))
dic = {}
for i in range(1, n + 1):
    S1 = sum(arr[:i])
    S2 = sum(arr[i:])
    dic[i] = abs(S1 - S2)
ans = sorted(list(dic.items()), key=lambda x: x[1])
print((ans[0][1]))

N = int(eval(input()))
A = list(map(int, input().split()))
ans = 1 << 60
for t in range(1, N):
    L = sum(A[:t])
    R = sum(A[t:])
    ans = min(ans, abs(L - R))
print(ans)

-n = int(eval(input())) -arr = list(map(int, input().split())) -dic = {} -for i in range(1, n + 1): -    S1 = sum(arr[:i]) -    S2 = sum(arr[i:]) -    dic[i] = abs(S1 - S2) -ans = sorted(list(dic.items()), key=lambda x: x[1]) -print((ans[0][1])) +N = int(eval(input())) +A = list(map(int, input().split())) +ans = 1 << 60 +for t in range(1, N): +    L = sum(A[:t]) +    R = sum(A[t:]) +    ans = min(ans, abs(L - R)) +print(ans)