N = int(input())
W = list(map(int,input().split()))
sum_front_N = sum(W)
sum_back_N = 0
ans = sum_front_N
for i in W:
    sum_back_N +=i
    sum_front_N -=i
    ans = min(ans,abs(sum_front_N - sum_back_N))
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 sum_front_N = sum(W) sum_front_N sum(W) sum W sum_back_N = 0 sum_back_N 0 ans = sum_front_N ans sum_front_N for i in W:
    sum_back_N +=i
    sum_front_N -=i
    ans = min(ans,abs(sum_front_N - sum_back_N)) i W sum_back_N +=i sum_back_N i sum_front_N -=i sum_front_N i ans = min(ans,abs(sum_front_N - sum_back_N)) ans min(ans,abs(sum_front_N - sum_back_N)) min ans abs(sum_front_N - sum_back_N) abs sum_front_N - sum_back_N sum_front_N sum_back_N print(ans) print ans sum_front_N = sum(W) sum(W) sum_front_N sum_front_N -=i i sum_front_N sum_back_N = 0 0 sum_back_N ans = sum_front_N sum_front_N ans ans = min(ans,abs(sum_front_N - sum_back_N)) min(ans,abs(sum_front_N - sum_back_N)) ans sum_back_N +=i i sum_back_N 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()))
sum_front_N = sum(W)
sum_back_N = 0
ans = sum_front_N
for i in W:
    sum_back_N +=i
    sum_front_N -=i
    ans = min(ans,abs(sum_front_N - sum_back_N))
print(ans)