n=int(input())
a=l=list(map(int, input().split()))
ans=100000
Sum=sum(a)
cnt=0
for i in range(n):
  cnt+=a[i]
  ans=min(abs(Sum-2*cnt),ans)
print(ans) n=int(input()) n int(input()) int input() input a=l=list(map(int, input().split())) a list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split =l=list(map(int, input().split())) l list(map(int, input().split())) ans=100000 ans 100000 Sum=sum(a) Sum sum(a) sum a cnt=0 cnt 0 for i in range(n):
  cnt+=a[i]
  ans=min(abs(Sum-2*cnt),ans) i range(n) range n cnt+=a[i] cnt a[i] a i ans=min(abs(Sum-2*cnt),ans) ans min(abs(Sum-2*cnt),ans) min abs(Sum-2*cnt) abs Sum-2*cnt Sum 2*cnt 2 cnt ans print(ans) print ans Sum=sum(a) sum(a) Sum n=int(input()) int(input()) n a=l=list(map(int, input().split())) list(map(int, input().split())) a ans=100000 100000 ans cnt=0 0 cnt cnt+=a[i] a[i] cnt l=list(map(int, input().split())) list(map(int, input().split())) l ans=min(abs(Sum-2*cnt),ans) min(abs(Sum-2*cnt),ans) ans
n=int(input())
a=l=list(map(int, input().split()))
ans=100000
Sum=sum(a)
cnt=0
for i in range(n):
  cnt+=a[i]
  ans=min(abs(Sum-2*cnt),ans)
print(ans)