N = int(eval(input()))

a= list(map(int, input().split()))



left = [0] * N

right = [0] * N



left[0] = a[0]

right[-1] = a[-1]

for i in range(1, N):

    left[i] = a[i] + left[i-1]

for i in range(N-2, -1, -1):

    right[i] = a[i] + right[i+1]



# print(left)

# print(right)

ans = abs(left[0] - right[1])

for i in range(1, N-1):

    ans = min(ans, abs(left[i] - right[i+1]))

print(ans)

import sys

input = sys.stdin.readline



def main():

    N = int(eval(input()))

    a = list(map(int, input().split()))



    left = [0] * N

    left[0] = a[0]

    for i in range(1, N):

        left[i] = left[i-1] + a[i]

    # print(left)

    ans = abs(left[-1] - 2 * left[0])

    for i in range(1, N-1):

        ans = min(ans, abs(left[-1] - 2 * left[i]))

    print(ans)



if __name__ == "__main__":

    main()
N = int(eval(input()))
a = list(map(int, input().split()))
left = [0] * N
right = [0] * N
left[0] = a[0]
right[-1] = a[-1]
for i in range(1, N):
    left[i] = a[i] + left[i - 1]
for i in range(N - 2, -1, -1):
    right[i] = a[i] + right[i + 1]
# print(left)
# print(right)
ans = abs(left[0] - right[1])
for i in range(1, N - 1):
    ans = min(ans, abs(left[i] - right[i + 1]))
print(ans)

import sys

input = sys.stdin.readline


def main():
    N = int(eval(input()))
    a = list(map(int, input().split()))
    left = [0] * N
    left[0] = a[0]
    for i in range(1, N):
        left[i] = left[i - 1] + a[i]
    # print(left)
    ans = abs(left[-1] - 2 * left[0])
    for i in range(1, N - 1):
        ans = min(ans, abs(left[-1] - 2 * left[i]))
    print(ans)


if __name__ == "__main__":
    main()

-N = int(eval(input())) -a = list(map(int, input().split())) -left = [0] * N -right = [0] * N -left[0] = a[0] -right[-1] = a[-1] -for i in range(1, N): -    left[i] = a[i] + left[i - 1] -for i in range(N - 2, -1, -1): -    right[i] = a[i] + right[i + 1] -# print(left) -# print(right) -ans = abs(left[0] - right[1]) -for i in range(1, N - 1): -    ans = min(ans, abs(left[i] - right[i + 1])) -print(ans) +import sys + +input = sys.stdin.readline + + +def main(): +    N = int(eval(input())) +    a = list(map(int, input().split())) +    left = [0] * N +    left[0] = a[0] +    for i in range(1, N): +        left[i] = left[i - 1] + a[i] +    # print(left) +    ans = abs(left[-1] - 2 * left[0]) +    for i in range(1, N - 1): +        ans = min(ans, abs(left[-1] - 2 * left[i])) +    print(ans) + + +if __name__ == "__main__": +    main()