n = int(eval(input()))

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



ret = 10 ** 15



s = 0

t = sum(a)

a.pop()  # 最後の要素は取れない

for x in a:

    s += x

    t -= x

    ret = min(ret, abs(s - t))



print(ret)

def main():

    N = int(eval(input()))

    A = tuple(map(int, input().split()))



    tot = sum(A)



    ans = (10 ** 9) * (2 * 10 ** 5) + 1

    s = 0

    for x in A[:-1]:

        s += x + x

        diff = abs(tot - s)

        if ans > diff:

            ans = diff



    print(ans)





if __name__ == '__main__':

    main()

n = int(eval(input()))
(*a,) = list(map(int, input().split()))
ret = 10**15
s = 0
t = sum(a)
a.pop()  # 最後の要素は取れない
for x in a:
    s += x
    t -= x
    ret = min(ret, abs(s - t))
print(ret)

def main():
    N = int(eval(input()))
    A = tuple(map(int, input().split()))
    tot = sum(A)
    ans = (10**9) * (2 * 10**5) + 1
    s = 0
    for x in A[:-1]:
        s += x + x
        diff = abs(tot - s)
        if ans > diff:
            ans = diff
    print(ans)


if __name__ == "__main__":
    main()

-n = int(eval(input())) -(*a,) = list(map(int, input().split())) -ret = 10**15 -s = 0 -t = sum(a) -a.pop()  # 最後の要素は取れない -for x in a: -    s += x -    t -= x -    ret = min(ret, abs(s - t)) -print(ret) +def main(): +    N = int(eval(input())) +    A = tuple(map(int, input().split())) +    tot = sum(A) +    ans = (10**9) * (2 * 10**5) + 1 +    s = 0 +    for x in A[:-1]: +        s += x + x +        diff = abs(tot - s) +        if ans > diff: +            ans = diff +    print(ans) + + +if __name__ == "__main__": +    main()