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: import sys
  import math
  import collections
  import itertools
  import array
  import inspect
  
  # Set max recursion limit
  sys.setrecursionlimit(1000000)
  
  
  # Debug output
  def chkprint(*args):
      names = {id(v): k for k, v in inspect.currentframe().f_back.f_locals.items()}
      print(", ".join(names.get(id(arg), "???") + " = " + repr(arg) for arg in args))
  
  
  # Binary converter
  def to_bin(x):
      return bin(x)[2:]
  
  
  def li_input():
      return [int(_) for _ in input().split()]
  
  
  def gcd(n, m):
      if n % m == 0:
          return m
      else:
          return gcd(m, n % m)
  
  
  def gcd_list(L):
      v = L[0]
  
      for i in range(1, len(L)):
          v = gcd(v, L[i])
  
      return v
  
  
  def lcm(n, m):
      return (n * m) // gcd(n, m)
  
  
  def lcm_list(L):
      v = L[0]
  
      for i in range(1, len(L)):
          v = lcm(v, L[i])
  
      return v
  
  
  # Width First Search (+ Distance)
  def wfs_d(D, N, K):
      """
      D: 隣接行列(距離付き)
      N: ノード数
      K: 始点ノード
      """
  
      dfk = [-1] * (N + 1)
      dfk[K] = 0
  
      cps = [(K, 0)]
      r = [False] * (N + 1)
      r[K] = True
      while len(cps) != 0:
          n_cps = []
          for cp, cd in cps:
              for i, dfcp in enumerate(D[cp]):
                  if dfcp != -1 and not r[i]:
                      dfk[i] = cd + dfcp
                      n_cps.append((i, cd + dfcp))
                      r[i] = True
  
          cps = n_cps[:]
  
      return dfk
  
  
  # Depth First Search (+Distance)
  def dfs_d(v, pre, dist):
      """
      v:  現在のノード
      pre: １つ前のノード
      dist: 現在の距離
  
      以下は別途用意する
      D: 隣接リスト(行列ではない)
      D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
      """
  
      global D
      global D_dfs_d
  
      D_dfs_d[v] = dist
  
      for next_v, d in D[v]:
          if next_v != pre:
              dfs_d(next_v, v, dist + d)
  
      return
  
  
  # --------------------------------------------
  
  dp = None
  
  
  def main():
      N = int(input())
      A = li_input()
      C = []
  
      tmpsum = 0
      for a in A:
          tmpsum += a
          C.append(tmpsum)
  
      ans = 10**100
  
      for i in range(len(C) - 1):
          ans = min(ans, abs((C[-1] - C[i]) - C[i]))
  
      print(ans)
  
  
  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."}]