def main():
    N = int(input())
    W = list(map(int, input().split()))
    ans = 10 ** 10
    lst = [0 for _ in range(N)]
    lst[0] = W[0]

    for i in range(1, N):
        lst[i] = lst[i - 1] + W[i]

    for T in range(N - 1):
        S1 = lst[T]
        S2 = lst[-1] - lst[T]
        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
    lst = [0 for _ in range(N)]
    lst[0] = W[0]

    for i in range(1, N):
        lst[i] = lst[i - 1] + W[i]

    for T in range(N - 1):
        S1 = lst[T]
        S2 = lst[-1] - lst[T]
        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 0 for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) 0 lst = [0 for _ in range(N)] lst [0 for _ in range(N)] lst[0] = W[0] lst[0] lst 0 W[0] W 0 for i in range(1, N):
        lst[i] = lst[i - 1] + W[i]

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

     T range(N - 1) range N - 1 N 1 S1 = lst[T] S1 lst[T] lst T S2 = lst[-1] - lst[T] S2 lst[-1] - lst[T] lst[-1] lst -1 lst[T] lst T 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
    lst = [0 for _ in range(N)]
    lst[0] = W[0]

    for i in range(1, N):
        lst[i] = lst[i - 1] + W[i]

    for T in range(N - 1):
        S1 = lst[T]
        S2 = lst[-1] - lst[T]
        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
    lst = [0 for _ in range(N)]
    lst[0] = W[0]

    for i in range(1, N):
        lst[i] = lst[i - 1] + W[i]

    for T in range(N - 1):
        S1 = lst[T]
        S2 = lst[-1] - lst[T]
        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
    lst = [0 for _ in range(N)]
    lst[0] = W[0]

    for i in range(1, N):
        lst[i] = lst[i - 1] + W[i]

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

    print(ans)


if __name__ == "__main__":
    main()
