import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    w = list(map(int, input().split()))
    ans = float('inf')
    for t in range(n-1):
        ans = min(ans, abs(sum(w[:t+1]) - sum(w[t+1:])))
    print(ans)
    
if __name__ == '__main__':
    main() import sys sys input = lambda: sys.stdin.readline().rstrip() input lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip def main():
    n = int(input())
    w = list(map(int, input().split()))
    ans = float('inf')
    for t in range(n-1):
        ans = min(ans, abs(sum(w[:t+1]) - sum(w[t+1:])))
    print(ans)
     main 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 ans = float('inf') ans float('inf') float 'inf' for t in range(n-1):
        ans = min(ans, abs(sum(w[:t+1]) - sum(w[t+1:])))
     t range(n-1) range n-1 n 1 ans = min(ans, abs(sum(w[:t+1]) - sum(w[t+1:]))) ans min(ans, abs(sum(w[:t+1]) - sum(w[t+1:]))) min ans abs(sum(w[:t+1]) - sum(w[t+1:])) abs sum(w[:t+1]) - sum(w[t+1:]) sum(w[:t+1]) sum w[:t+1] w :t+1 t+1 t 1 sum(w[t+1:]) sum w[t+1:] w t+1: t+1 t 1 print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    n = int(input())
    w = list(map(int, input().split()))
    ans = float('inf')
    for t in range(n-1):
        ans = min(ans, abs(sum(w[:t+1]) - sum(w[t+1:])))
    print(ans)
     def main():
    n = int(input())
    w = list(map(int, input().split()))
    ans = float('inf')
    for t in range(n-1):
        ans = min(ans, abs(sum(w[:t+1]) - sum(w[t+1:])))
    print(ans)
     main input = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() input
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    w = list(map(int, input().split()))
    ans = float('inf')
    for t in range(n-1):
        ans = min(ans, abs(sum(w[:t+1]) - sum(w[t+1:])))
    print(ans)
    
if __name__ == '__main__':
    main()