output_description: Print the answer.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      a_1 a_2 ... a_{N}
attempt: from copy import *
  from sys import *
  import math
  import queue
  from collections import defaultdict, Counter, deque
  from fractions import Fraction as frac
  
  setrecursionlimit(1000000)
  
  
  def main():
      n = int(input())
      a = list(map(int, input().split()))
      r = [a[0]]
      for i in range(1, n):
          r.append(r[i - 1] + a[i])
      s = sum(a)
      m = []
      for i in range(n - 1):
          m.append(abs(2 * r[i] - s))
      print(min(m))
  
  
  def zip(a):
      mae = a[0]
      ziparray = [mae]
      for i in range(1, len(a)):
          if mae != a[i]:
              ziparray.append(a[i])
              mae = a[i]
      return ziparray
  
  
  def is_prime(n):
      if n < 2:
          return False
  
      for k in range(2, int(math.sqrt(n)) + 1):
          if n % k == 0:
              return False
  
      return True
  
  
  def list_replace(n, f, t):
      return [t if i == f else i for i in n]
  
  
  def base_10_to_n(X, n):
      X_dumy = X
      out = ""
      while X_dumy > 0:
          out = str(X_dumy % n) + out
          X_dumy = int(X_dumy / n)
      if out == "":
          return "0"
      return out
  
  
  def gcd(m, n):
      x = max(m, n)
      y = min(m, n)
      while x % y != 0:
          z = x % y
          x = y
          y = z
      return y
  
  
  class Queue:
      def __init__(self):
          self.q = deque([])
  
      def push(self, i):
          self.q.append(i)
  
      def pop(self):
          return self.q.popleft()
  
      def size(self):
          return len(self.q)
  
      def debug(self):
          return self.q
  
  
  class Stack:
      def __init__(self):
          self.q = []
  
      def push(self, i):
          self.q.append(i)
  
      def pop(self):
          return self.q.pop()
  
      def size(self):
          return len(self.q)
  
      def debug(self):
          return self.q
  
  
  class graph:
      def __init__(self):
          self.graph = defaultdict(list)
  
      def addnode(self, l):
          f, t = l[0], l[1]
          self.graph[f].append(t)
          self.graph[t].append(f)
  
      def rmnode(self, l):
          f, t = l[0], l[1]
          self.graph[f].remove(t)
          self.graph[t].remove(f)
  
      def linked(self, f):
          return self.graph[f]
  
  
  class dgraph:
      def __init__(self):
          self.graph = defaultdict(set)
  
      def addnode(self, l):
          f, t = l[0], l[1]
          self.graph[f].append(t)
  
      def rmnode(self, l):
          f, t = l[0], l[1]
          self.graph[f].remove(t)
  
      def linked(self, f):
          return self.graph[f]
  
  
  main()
  
problem_description: Statement
  
  Snuke and Raccoon have a heap of N cards. The i-th card from the top has the
  integer a_i written on it.
  
  They will share these cards. First, Snuke will take some number of cards from
  the top of the heap, then Raccoon will take all the remaining cards. Here,
  both Snuke and Raccoon have to take at least one card.
  
  Let the sum of the integers on Snuke's cards and Raccoon's cards be x and y,
  respectively. They would like to minimize |x-y|. Find the minimum possible
  value of |x-y|.
samples: [{"input": "6\n    1 2 3 4 5 6", "output": "1\n    \n\nIf Snuke takes four cards from the top, and Raccoon takes the remaining two\ncards, x=10, y=11, and thus |x-y|=1. This is the minimum possible value.\n\n* * *"}, {"input": "2\n    10 -10", "output": "20\n    \n\nSnuke can only take one card from the top, and Raccoon can only take the\nremaining one card. In this case, x=10, y=-10, and thus |x-y|=20."}]