N = int(input())
W = list(map(int, input().split()))
S = [0]
for i in range(N):
  S.append(S[i] + W[i])
ans = float("inf")
for j in range(N):
  ans = min(abs(S[-1] - 2*S[j]), ans)
print(ans) 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 S = [0] S [0] 0 for i in range(N):
  S.append(S[i] + W[i]) i range(N) range N S.append(S[i] + W[i]) S.append S append S[i] + W[i] S[i] S i W[i] W i ans = float("inf") ans float("inf") float "inf" for j in range(N):
  ans = min(abs(S[-1] - 2*S[j]), ans) j range(N) range N ans = min(abs(S[-1] - 2*S[j]), ans) ans min(abs(S[-1] - 2*S[j]), ans) min abs(S[-1] - 2*S[j]) abs S[-1] - 2*S[j] S[-1] S -1 2*S[j] 2 S[j] S j ans print(ans) print ans S = [0] [0] S N = int(input()) int(input()) N ans = min(abs(S[-1] - 2*S[j]), ans) min(abs(S[-1] - 2*S[j]), ans) ans ans = float("inf") float("inf") ans W = list(map(int, input().split())) list(map(int, input().split())) W
N = int(input())
W = list(map(int, input().split()))
S = [0]
for i in range(N):
  S.append(S[i] + W[i])
ans = float("inf")
for j in range(N):
  ans = min(abs(S[-1] - 2*S[j]), ans)
print(ans)