import sys
N = int(input())
array = list(map(int,input().split()))

result = sum(array)
for I in range(len(array)):
    tmp = abs(sum(array[0:I]) - sum(array[I:]))
    if result > tmp: result = tmp
print(result) import sys sys N = int(input()) N int(input()) int input() input array = list(map(int,input().split())) array list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split result = sum(array) result sum(array) sum array for I in range(len(array)):
    tmp = abs(sum(array[0:I]) - sum(array[I:]))
    if result > tmp: result = tmp I range(len(array)) range len(array) len array tmp = abs(sum(array[0:I]) - sum(array[I:])) tmp abs(sum(array[0:I]) - sum(array[I:])) abs sum(array[0:I]) - sum(array[I:]) sum(array[0:I]) sum array[0:I] array 0:I 0 I sum(array[I:]) sum array[I:] array I: I if result > tmp: result = result > tmp result tmp print(result) print result N = int(input()) int(input()) N result = sum(array) sum(array) result array = list(map(int,input().split())) list(map(int,input().split())) array tmp = abs(sum(array[0:I]) - sum(array[I:])) abs(sum(array[0:I]) - sum(array[I:])) tmp
import sys
N = int(input())
array = list(map(int,input().split()))

result = sum(array)
for I in range(len(array)):
    tmp = abs(sum(array[0:I]) - sum(array[I:]))
    if result > tmp: result = tmp
print(result)