# -*- coding: utf-8 -*-
from sys import stdin
input = stdin.readline
import numpy as np

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


temp = 1e+9
for i in range(N):
    res = np.array(W[:i]).sum()
    pos = np.array(W[i:]).sum()

    if(abs(res - pos) < temp):
        temp = abs(res - pos)

print(temp) from sys import stdin input = stdin.readline input stdin.readline stdin readline import numpy as np numpy 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 temp = 1e+9 temp 1e+9 for i in range(N):
    res = np.array(W[:i]).sum()
    pos = np.array(W[i:]).sum()

    if(abs(res - pos) < temp):
        temp = abs(res - pos) i range(N) range N res = np.array(W[:i]).sum() res np.array(W[:i]).sum() np.array(W[:i]).sum np.array(W[:i]) np.array np array W[:i] W :i i sum pos = np.array(W[i:]).sum() pos np.array(W[i:]).sum() np.array(W[i:]).sum np.array(W[i:]) np.array np array W[i:] W i: i sum if(abs(res - pos) < temp):
        temp = abs(res - pos) abs(res - pos) < temp abs(res - pos) abs res - pos res pos temp temp = abs(res - pos) temp abs(res - pos) abs res - pos res pos print(temp) print temp temp = abs(res - pos) abs(res - pos) temp res = np.array(W[:i]).sum() np.array(W[:i]).sum() res W = list(map(int,input().split())) list(map(int,input().split())) W pos = np.array(W[i:]).sum() np.array(W[i:]).sum() pos N = int(input()) int(input()) N input = stdin.readline stdin.readline input temp = 1e+9 1e+9 temp
# -*- coding: utf-8 -*-
from sys import stdin
input = stdin.readline
import numpy as np

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


temp = 1e+9
for i in range(N):
    res = np.array(W[:i]).sum()
    pos = np.array(W[i:]).sum()

    if(abs(res - pos) < temp):
        temp = abs(res - pos)

print(temp)