import numpy as np
n = int(input())
W = np.array(list(map(int, input().split())))
T = np.sum(W)
S = np.cumsum(W)
ans = np.min(np.abs(T - S - S))
print(ans) import numpy as np numpy n = int(input()) n int(input()) int input() input W = np.array(list(map(int, input().split()))) W np.array(list(map(int, input().split()))) np.array np array list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split T = np.sum(W) T np.sum(W) np.sum np sum W S = np.cumsum(W) S np.cumsum(W) np.cumsum np cumsum W ans = np.min(np.abs(T - S - S)) ans np.min(np.abs(T - S - S)) np.min np min np.abs(T - S - S) np.abs np abs T - S - S T - S T S S print(ans) print ans n = int(input()) int(input()) n T = np.sum(W) np.sum(W) T S = np.cumsum(W) np.cumsum(W) S ans = np.min(np.abs(T - S - S)) np.min(np.abs(T - S - S)) ans W = np.array(list(map(int, input().split()))) np.array(list(map(int, input().split()))) W
import numpy as np
n = int(input())
W = np.array(list(map(int, input().split())))
T = np.sum(W)
S = np.cumsum(W)
ans = np.min(np.abs(T - S - S))
print(ans)
