N=int(input())
W=list(map(int,input().split()))
S1=0;S2=0;
diff=[]
for i in range(N):
  S1+=W[i]
  S2=sum(W)-S1
  diff.append(abs(S1-S2))
print(min(diff)) N=int(input()) N int(input()) int input() input W=list(map(int,input().split())) W list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split S1=0 S1 0 S2=0 S2 0 diff=[] diff [] for i in range(N):
  S1+=W[i]
  S2=sum(W)-S1
  diff.append(abs(S1-S2)) i range(N) range N S1+=W[i] S1 W[i] W i S2=sum(W)-S1 S2 sum(W)-S1 sum(W) sum W S1 diff.append(abs(S1-S2)) diff.append diff append abs(S1-S2) abs S1-S2 S1 S2 print(min(diff)) print min(diff) min diff S1=0 0 S1 S2=0 0 S2 S2=sum(W)-S1 sum(W)-S1 S2 S1+=W[i] W[i] S1 diff=[] [] diff N=int(input()) int(input()) N W=list(map(int,input().split())) list(map(int,input().split())) W
N=int(input())
W=list(map(int,input().split()))
S1=0;S2=0;
diff=[]
for i in range(N):
  S1+=W[i]
  S2=sum(W)-S1
  diff.append(abs(S1-S2))
print(min(diff))