from itertools import accumulate





def main():

    n = int(eval(input()))

    lst = tuple(accumulate(list(map(int, input().rstrip().split()))))

    ans = min(abs(lst[-1] - i * 2) for i in lst[:-1])

    print(ans)





if __name__ == "__main__":

    main()
from itertools import accumulate





def main():

    n = int(eval(input()))

    lst = tuple(accumulate(list(map(int, input().rstrip().split()))))

    total = lst[-1]

    ans = min(abs(total - i * 2) for i in lst[:-1])

    print(ans)





if __name__ == "__main__":

    main()
from itertools import accumulate


def main():
    n = int(eval(input()))
    lst = tuple(accumulate(list(map(int, input().rstrip().split()))))
    ans = min(abs(lst[-1] - i * 2) for i in lst[:-1])
    print(ans)


if __name__ == "__main__":
    main()

from itertools import accumulate


def main():
    n = int(eval(input()))
    lst = tuple(accumulate(list(map(int, input().rstrip().split()))))
    total = lst[-1]
    ans = min(abs(total - i * 2) for i in lst[:-1])
    print(ans)


if __name__ == "__main__":
    main()

-    ans = min(abs(lst[-1] - i * 2) for i in lst[:-1]) +    total = lst[-1] +    ans = min(abs(total - i * 2) for i in lst[:-1])