def main():
    n = int(input())
    w_lst = list(map(int, input().split()))
    difference_lst = []

    for i in range(1, n):
        s1 = 0
        s2 = 0

        for j in range(i):
            s1 += w_lst[j]
        for j in range(i, n):
            s2 += w_lst[j]

        difference_lst.append(abs(s1 - s2))

    minimum = min(difference_lst)
    print(minimum)


if __name__ == '__main__':
    main() def main():
    n = int(input())
    w_lst = list(map(int, input().split()))
    difference_lst = []

    for i in range(1, n):
        s1 = 0
        s2 = 0

        for j in range(i):
            s1 += w_lst[j]
        for j in range(i, n):
            s2 += w_lst[j]

        difference_lst.append(abs(s1 - s2))

    minimum = min(difference_lst)
    print(minimum) main n = int(input()) n int(input()) int input() input w_lst = list(map(int, input().split())) w_lst list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split difference_lst = [] difference_lst [] for i in range(1, n):
        s1 = 0
        s2 = 0

        for j in range(i):
            s1 += w_lst[j]
        for j in range(i, n):
            s2 += w_lst[j]

        difference_lst.append(abs(s1 - s2))

     i range(1, n) range 1 n s1 = 0 s1 0 s2 = 0 s2 0 for j in range(i):
            s1 += w_lst[j]
         j range(i) range i s1 += w_lst[j] s1 w_lst[j] w_lst j for j in range(i, n):
            s2 += w_lst[j]

         j range(i, n) range i n s2 += w_lst[j] s2 w_lst[j] w_lst j difference_lst.append(abs(s1 - s2)) difference_lst.append difference_lst append abs(s1 - s2) abs s1 - s2 s1 s2 minimum = min(difference_lst) minimum min(difference_lst) min difference_lst print(minimum) print minimum if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    n = int(input())
    w_lst = list(map(int, input().split()))
    difference_lst = []

    for i in range(1, n):
        s1 = 0
        s2 = 0

        for j in range(i):
            s1 += w_lst[j]
        for j in range(i, n):
            s2 += w_lst[j]

        difference_lst.append(abs(s1 - s2))

    minimum = min(difference_lst)
    print(minimum) def main():
    n = int(input())
    w_lst = list(map(int, input().split()))
    difference_lst = []

    for i in range(1, n):
        s1 = 0
        s2 = 0

        for j in range(i):
            s1 += w_lst[j]
        for j in range(i, n):
            s2 += w_lst[j]

        difference_lst.append(abs(s1 - s2))

    minimum = min(difference_lst)
    print(minimum) main
def main():
    n = int(input())
    w_lst = list(map(int, input().split()))
    difference_lst = []

    for i in range(1, n):
        s1 = 0
        s2 = 0

        for j in range(i):
            s1 += w_lst[j]
        for j in range(i, n):
            s2 += w_lst[j]

        difference_lst.append(abs(s1 - s2))

    minimum = min(difference_lst)
    print(minimum)


if __name__ == '__main__':
    main()