N = int(input())
W = list(map(int, input().split()))
w_sum = sum(W)

val_sum = 0
val_diff = w_sum
for i in range(N):
    val_sum += W[i]
    diff = abs(2 * val_sum - w_sum)
    if diff < val_diff:
        val_diff = diff
    else:
        break

print(val_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 w_sum = sum(W) w_sum sum(W) sum W val_sum = 0 val_sum 0 val_diff = w_sum val_diff w_sum for i in range(N):
    val_sum += W[i]
    diff = abs(2 * val_sum - w_sum)
    if diff < val_diff:
        val_diff = diff
    else:
        break i range(N) range N val_sum += W[i] val_sum W[i] W i diff = abs(2 * val_sum - w_sum) diff abs(2 * val_sum - w_sum) abs 2 * val_sum - w_sum 2 * val_sum 2 val_sum w_sum if diff < val_diff:
        val_diff = diff
    else:
        break diff < val_diff diff val_diff val_diff = diff val_diff diff break print(val_diff) print val_diff N = int(input()) int(input()) N W = list(map(int, input().split())) list(map(int, input().split())) W diff = abs(2 * val_sum - w_sum) abs(2 * val_sum - w_sum) diff w_sum = sum(W) sum(W) w_sum val_diff = w_sum w_sum val_diff val_sum += W[i] W[i] val_sum val_diff = diff diff val_diff val_sum = 0 0 val_sum
N = int(input())
W = list(map(int, input().split()))
w_sum = sum(W)

val_sum = 0
val_diff = w_sum
for i in range(N):
    val_sum += W[i]
    diff = abs(2 * val_sum - w_sum)
    if diff < val_diff:
        val_diff = diff
    else:
        break

print(val_diff)