# -*- coding: utf-8 -*-

def main():

    N = int(input())
    W = list(map(int, input().split()))

    absW = []

    for i in range(N):
        absW.append(abs(sum(W[:i + 1]) - sum(W[i + 1:])))

    ans = min(absW)

    print(ans)


if __name__ == "__main__":
    main() def main():

    N = int(input())
    W = list(map(int, input().split()))

    absW = []

    for i in range(N):
        absW.append(abs(sum(W[:i + 1]) - sum(W[i + 1:])))

    ans = min(absW)

    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 absW = [] absW [] for i in range(N):
        absW.append(abs(sum(W[:i + 1]) - sum(W[i + 1:])))

     i range(N) range N absW.append(abs(sum(W[:i + 1]) - sum(W[i + 1:]))) absW.append absW append abs(sum(W[:i + 1]) - sum(W[i + 1:])) abs sum(W[:i + 1]) - sum(W[i + 1:]) sum(W[:i + 1]) sum W[:i + 1] W :i + 1 i + 1 i 1 sum(W[i + 1:]) sum W[i + 1:] W i + 1: i + 1 i 1 ans = min(absW) ans min(absW) min absW 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()))

    absW = []

    for i in range(N):
        absW.append(abs(sum(W[:i + 1]) - sum(W[i + 1:])))

    ans = min(absW)

    print(ans) def main():

    N = int(input())
    W = list(map(int, input().split()))

    absW = []

    for i in range(N):
        absW.append(abs(sum(W[:i + 1]) - sum(W[i + 1:])))

    ans = min(absW)

    print(ans) main
# -*- coding: utf-8 -*-

def main():

    N = int(input())
    W = list(map(int, input().split()))

    absW = []

    for i in range(N):
        absW.append(abs(sum(W[:i + 1]) - sum(W[i + 1:])))

    ans = min(absW)

    print(ans)


if __name__ == "__main__":
    main()