# -*- coding: utf-8 -*-

"""

Created on Tue Jan 28 00:14:43 2020



@author: H_Hoshigi

"""



N = int(eval(input()))

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



sunuke = a_list[0]

araiguma = sum(a_list[1:])

min_difference = abs(sunuke - araiguma)



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

    sunuke += a_list[i]

    araiguma -= a_list[i]

    min_difference = min(min_difference,

                         abs(sunuke - araiguma))



print(min_difference)

# -*- coding: utf-8 -*-

"""

Created on Tue Jan 28 00:29:09 2020



@author: H_Hoshigi

"""

import sys



N = int(eval(input()))

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





#sunuke = a_list[0]

#araiguma = sum(a_list[1:])

#min_difference = abs(sunuke - araiguma)

sunuke = 0

sum_a = sum(a_list)



min_difference = sys.maxsize

#abs(sunuke - araiguma)は、abs(sum(a_list)-sunuke*2)として求められる。



#range(1,N-1)ではなく、最初の一枚目から比較する形にした。

for i in range(N-1):

    sunuke += a_list[i]

    #araiguma -= a_list[i]

    min_difference = min(min_difference,

                         abs(sum_a - 2*sunuke))



print(min_difference)

# -*- coding: utf-8 -*-
"""
Created on Tue Jan 28 00:14:43 2020
@author: H_Hoshigi
"""
N = int(eval(input()))
a_list = list(map(int, input().split()))
sunuke = a_list[0]
araiguma = sum(a_list[1:])
min_difference = abs(sunuke - araiguma)
for i in range(1, N - 1):
    sunuke += a_list[i]
    araiguma -= a_list[i]
    min_difference = min(min_difference, abs(sunuke - araiguma))
print(min_difference)

# -*- coding: utf-8 -*-
"""
Created on Tue Jan 28 00:29:09 2020
@author: H_Hoshigi
"""
import sys

N = int(eval(input()))
a_list = list(map(int, input().split()))
# sunuke = a_list[0]
# araiguma = sum(a_list[1:])
# min_difference = abs(sunuke - araiguma)
sunuke = 0
sum_a = sum(a_list)
min_difference = sys.maxsize
# abs(sunuke - araiguma)は、abs(sum(a_list)-sunuke*2)として求められる。
# range(1,N-1)ではなく、最初の一枚目から比較する形にした。
for i in range(N - 1):
    sunuke += a_list[i]
    # araiguma -= a_list[i]
    min_difference = min(min_difference, abs(sum_a - 2 * sunuke))
print(min_difference)

-Created on Tue Jan 28 00:14:43 2020 +Created on Tue Jan 28 00:29:09 2020 +import sys + -sunuke = a_list[0] -araiguma = sum(a_list[1:]) -min_difference = abs(sunuke - araiguma) -for i in range(1, N - 1): +# sunuke = a_list[0] +# araiguma = sum(a_list[1:]) +# min_difference = abs(sunuke - araiguma) +sunuke = 0 +sum_a = sum(a_list) +min_difference = sys.maxsize +# abs(sunuke - araiguma)は、abs(sum(a_list)-sunuke*2)として求められる。 +# range(1,N-1)ではなく、最初の一枚目から比較する形にした。 +for i in range(N - 1): -    araiguma -= a_list[i] -    min_difference = min(min_difference, abs(sunuke - araiguma)) +    # araiguma -= a_list[i] +    min_difference = min(min_difference, abs(sum_a - 2 * sunuke))