def main():
    N = int(input())
    W = list(map(int, input().split()))
    ans = 10 ** 10

    for T in range(N - 1):
        S1 = sum(W[:T + 1])
        S2 = sum(W[T + 1:])
        diff = abs(S1 - S2)
        if diff < ans:
            ans = diff

    print(ans)


if __name__ == "__main__":
    main() def main():
    N = int(input())
    W = list(map(int, input().split()))
    ans = 10 ** 10

    for T in range(N - 1):
        S1 = sum(W[:T + 1])
        S2 = sum(W[T + 1:])
        diff = abs(S1 - S2)
        if diff < ans:
            ans = diff

    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 = 10 ** 10 ans 10 ** 10 10 10 for T in range(N - 1):
        S1 = sum(W[:T + 1])
        S2 = sum(W[T + 1:])
        diff = abs(S1 - S2)
        if diff < ans:
            ans = diff

     T range(N - 1) range N - 1 N 1 S1 = sum(W[:T + 1]) S1 sum(W[:T + 1]) sum W[:T + 1] W :T + 1 T + 1 T 1 S2 = sum(W[T + 1:]) S2 sum(W[T + 1:]) sum W[T + 1:] W T + 1: T + 1 T 1 diff = abs(S1 - S2) diff abs(S1 - S2) abs S1 - S2 S1 S2 if diff < ans:
            ans = diff

     diff < ans diff ans ans = diff ans diff 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 = 10 ** 10

    for T in range(N - 1):
        S1 = sum(W[:T + 1])
        S2 = sum(W[T + 1:])
        diff = abs(S1 - S2)
        if diff < ans:
            ans = diff

    print(ans) def main():
    N = int(input())
    W = list(map(int, input().split()))
    ans = 10 ** 10

    for T in range(N - 1):
        S1 = sum(W[:T + 1])
        S2 = sum(W[T + 1:])
        diff = abs(S1 - S2)
        if diff < ans:
            ans = diff

    print(ans) main
def main():
    N = int(input())
    W = list(map(int, input().split()))
    ans = 10 ** 10

    for T in range(N - 1):
        S1 = sum(W[:T + 1])
        S2 = sum(W[T + 1:])
        diff = abs(S1 - S2)
        if diff < ans:
            ans = diff

    print(ans)


if __name__ == "__main__":
    main()
