import sys
from collections import defaultdict


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    W = list(map(int, input().split()))
    g = sum(W)
    ans = 10**6
    for i in range(1,N):
        t = abs(g-2*sum(W[:i]))
        ans = min(ans,t)

    print(ans)

if __name__ == "__main__":
    main() import sys sys from collections import defaultdict def input():
    return sys.stdin.readline().rstrip() input return 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()))
    g = sum(W)
    ans = 10**6
    for i in range(1,N):
        t = abs(g-2*sum(W[:i]))
        ans = min(ans,t)

    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 g = sum(W) g sum(W) sum W ans = 10**6 ans 10**6 10 6 for i in range(1,N):
        t = abs(g-2*sum(W[:i]))
        ans = min(ans,t)

     i range(1,N) range 1 N t = abs(g-2*sum(W[:i])) t abs(g-2*sum(W[:i])) abs g-2*sum(W[:i]) g 2*sum(W[:i]) 2 sum(W[:i]) sum W[:i] W :i i ans = min(ans,t) ans min(ans,t) min ans t 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()))
    g = sum(W)
    ans = 10**6
    for i in range(1,N):
        t = abs(g-2*sum(W[:i]))
        ans = min(ans,t)

    print(ans) def main():
    N = int(input())
    W = list(map(int, input().split()))
    g = sum(W)
    ans = 10**6
    for i in range(1,N):
        t = abs(g-2*sum(W[:i]))
        ans = min(ans,t)

    print(ans) main def input():
    return sys.stdin.readline().rstrip() def input():
    return sys.stdin.readline().rstrip() input
import sys
from collections import defaultdict


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    W = list(map(int, input().split()))
    g = sum(W)
    ans = 10**6
    for i in range(1,N):
        t = abs(g-2*sum(W[:i]))
        ans = min(ans,t)

    print(ans)

if __name__ == "__main__":
    main()
