input()
a = list(map(int,input().split()))
former = []
latter = []
difference = 1000
for i in range(1,len(a)):
    former = []
    latter = []
    for j in range(len(a)):
        if j <= i:
            former.append(a[j])
        else:
            latter.append(a[j])
    if abs(sum(former) - sum(latter)) < difference:
        difference = abs(sum(former) - sum(latter))
print(difference) input() input a = list(map(int,input().split())) a list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split former = [] former [] latter = [] latter [] difference = 1000 difference 1000 for i in range(1,len(a)):
    former = []
    latter = []
    for j in range(len(a)):
        if j <= i:
            former.append(a[j])
        else:
            latter.append(a[j])
    if abs(sum(former) - sum(latter)) < difference:
        difference = abs(sum(former) - sum(latter)) i range(1,len(a)) range 1 len(a) len a former = [] former [] latter = [] latter [] for j in range(len(a)):
        if j <= i:
            former.append(a[j])
        else:
            latter.append(a[j])
     j range(len(a)) range len(a) len a if j <= i:
            former.append(a[j])
        else:
            latter.append(a[j])
     j <= i j i former.append(a[j]) former.append former append a[j] a j latter.append(a[j]) latter.append latter append a[j] a j if abs(sum(former) - sum(latter)) < difference:
        difference = abs(sum(former) - sum(latter)) abs(sum(former) - sum(latter)) < difference abs(sum(former) - sum(latter)) abs sum(former) - sum(latter) sum(former) sum former sum(latter) sum latter difference difference = abs(sum(former) - sum(latter)) difference abs(sum(former) - sum(latter)) abs sum(former) - sum(latter) sum(former) sum former sum(latter) sum latter print(difference) print difference difference = abs(sum(former) - sum(latter)) abs(sum(former) - sum(latter)) difference difference = 1000 1000 difference former = [] [] former latter = [] [] latter a = list(map(int,input().split())) list(map(int,input().split())) a former = [] [] former latter = [] [] latter
input()
a = list(map(int,input().split()))
former = []
latter = []
difference = 1000
for i in range(1,len(a)):
    former = []
    latter = []
    for j in range(len(a)):
        if j <= i:
            former.append(a[j])
        else:
            latter.append(a[j])
    if abs(sum(former) - sum(latter)) < difference:
        difference = abs(sum(former) - sum(latter))
print(difference)