def solve():
    n = int(input())
    w = list(map(int, input().split()))
    dif = 1000
    for i in range(len(w)):
        dif = min(dif, abs(sum(w[:i]) - sum(w[i:])))
    print(dif)





if __name__ == '__main__':
    solve() def solve():
    n = int(input())
    w = list(map(int, input().split()))
    dif = 1000
    for i in range(len(w)):
        dif = min(dif, abs(sum(w[:i]) - sum(w[i:])))
    print(dif) solve 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 dif = 1000 dif 1000 for i in range(len(w)):
        dif = min(dif, abs(sum(w[:i]) - sum(w[i:])))
     i range(len(w)) range len(w) len w dif = min(dif, abs(sum(w[:i]) - sum(w[i:]))) dif min(dif, abs(sum(w[:i]) - sum(w[i:]))) min dif abs(sum(w[:i]) - sum(w[i:])) abs sum(w[:i]) - sum(w[i:]) sum(w[:i]) sum w[:i] w :i i sum(w[i:]) sum w[i:] w i: i print(dif) print dif if __name__ == '__main__':
    solve() __name__ == '__main__' __name__ '__main__' solve() solve def solve():
    n = int(input())
    w = list(map(int, input().split()))
    dif = 1000
    for i in range(len(w)):
        dif = min(dif, abs(sum(w[:i]) - sum(w[i:])))
    print(dif) def solve():
    n = int(input())
    w = list(map(int, input().split()))
    dif = 1000
    for i in range(len(w)):
        dif = min(dif, abs(sum(w[:i]) - sum(w[i:])))
    print(dif) solve
def solve():
    n = int(input())
    w = list(map(int, input().split()))
    dif = 1000
    for i in range(len(w)):
        dif = min(dif, abs(sum(w[:i]) - sum(w[i:])))
    print(dif)





if __name__ == '__main__':
    solve()
