# -*- Coding: utf-8 -*-

import numpy as np



N = int(input())

W = list(map(int,input().split()))

W = np.array(W)

W_sum = np.sum(W)

ans = W_sum

for i in range(1,N):

	right = np.sum(W[i:N])

	left = W_sum - right

	ans = min(ans,abs(left-right))



print(ans)

# -*- Coding: utf-8 -*-

import numpy as np



N = int(input())

W = list(map(int,input().split()))

W = np.array(W)

W_sum = np.sum(W)

ans = W_sum

left = 0

for i in range(N-1):

	left += W[i]

	right = W_sum - left

	ans = min(ans,abs(left-right))



print(ans)

# -*- Coding: utf-8 -*-
import numpy as np

N = int(input())
W = list(map(int, input().split()))
W = np.array(W)
W_sum = np.sum(W)
ans = W_sum
for i in range(1, N):
    right = np.sum(W[i:N])
    left = W_sum - right
    ans = min(ans, abs(left - right))
print(ans)

# -*- Coding: utf-8 -*-
import numpy as np

N = int(input())
W = list(map(int, input().split()))
W = np.array(W)
W_sum = np.sum(W)
ans = W_sum
left = 0
for i in range(N - 1):
    left += W[i]
    right = W_sum - left
    ans = min(ans, abs(left - right))
print(ans)

-for i in range(1, N): -    right = np.sum(W[i:N]) -    left = W_sum - right +left = 0 +for i in range(N - 1): +    left += W[i] +    right = W_sum - left