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|.

-----Constraints-----
 - 2 \leq N \leq 2 \times 10^5
 - -10^{9} \leq a_i \leq 10^{9}
 - a_i is an integer.

-----Input-----
Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_{N}

-----Output-----
Print the answer.

-----Sample Input-----
6
1 2 3 4 5 6

-----Sample Output-----
1

If Snuke takes four cards from the top, and Raccoon takes the remaining two cards, x=10, y=11, and thus |x-y|=1. This is the minimum possible value.
[{"code": "import sys\nimport itertools\n\nsys.setrecursionlimit(10 ** 8)\nini = lambda: int(sys.stdin.readline())\ninl = lambda: [int(x) for x in sys.stdin.readline().split()]\nins = lambda: sys.stdin.readline().rstrip()\ndebug = lambda *a, **kw: print(\"\\033[33m\", *a, \"\\033[0m\", **dict(file=sys.stderr, **kw))\n\nN = ini()\nA = inl()\n\n\ndef solve():\n    B = list(itertools.accumulate(A, initial=0))\n    s = 0\n    ans = 10 ** 12\n    for i in range(N - 1, 0, -1):\n        s += A[i]\n        ans = min(ans, abs(s - B[i]))\n\n    return ans\n\n\nprint(solve())\n", "passed": true, "time": 0.14, "memory": 14320.0, "status": "done"}, {"code": "n=int(input())\na=list(map(int,input().split()))\n\nt=sum(a)\nm=10**9\nflag=0\nfor i in range(len(a)-1):\n    t-=2*a[i]\n    if i==0:\n        m=abs(t)\n    else:\n        m=min(abs(t),m)\nprint(m)", "passed": true, "time": 0.57, "memory": 14232.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\n\nlsum = a[0]\nrsum = sum(a[1:])\nans = abs(lsum - rsum)\n\nfor i in range(1, n-1):\n    lsum += a[i]\n    rsum -= a[i]\n    res = abs(lsum - rsum)\n\n    if res < ans:\n        ans = res\n\nprint(ans)", "passed": true, "time": 0.15, "memory": 14220.0, "status": "done"}, {"code": "def main():\n    n = int(input())\n    a_lst = list(map(int, input().split()))\n    x = a_lst[0]\n    y = sum(a_lst) - x\n\n    minimum = abs(x - y)\n    for i in range(1, n - 1):\n        a = a_lst[i]\n        x += a\n        y -= a\n        minimum = min(minimum, abs(x - y))\n\n    print(minimum)\n\n\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.16, "memory": 14340.0, "status": "done"}, {"code": "N = int(input())\na = [int(x) for x in input().split()]\nans = 10**9*N\nfront = 0\nback = sum(a)\nfor i in range(N-1):\n    front += a[i]\n    back -= a[i]\n    ans = min(ans, abs(front-back))\nprint(ans)", "passed": true, "time": 0.14, "memory": 14096.0, "status": "done"}, {"code": "N = int(input())\nA = [0]+list(map(int,input().split()))\nfor i in range(1,N+1):\n  A[i] = A[i]+A[i-1]\nans = float('inf')\nfor i in range(1,N):\n  ans = min(ans, abs(A[N]-2*A[i]))\nprint(ans)", "passed": true, "time": 0.14, "memory": 14096.0, "status": "done"}, {"code": "import itertools\nn = int(input())\na = list(map(int, input().split(\" \")))\n#print(a)\nmini = 10 ** 10\nsuma = list(itertools.accumulate(a))\nfor i in range(0, n-1):\n  #print(suma[i],(suma[-1]))\n  mini = min(mini, abs(suma[-1]-suma[i]*2))\nprint(mini)", "passed": true, "time": 0.14, "memory": 14212.0, "status": "done"}, {"code": "n = int(input())\nA = list(map(int, input().split()))\nr = sum(A)-A[0]\nl = A[0]\nans = abs(r-l)\nfor i in range(1,len(A)-1):\n    r -= A[i]\n    l += A[i]\n    ans = min(ans, abs(l-r))\nprint(ans)", "passed": true, "time": 0.14, "memory": 14316.0, "status": "done"}, {"code": "import sys, re, os\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd\nfrom itertools import permutations, combinations, product, accumulate\nfrom operator import itemgetter, mul, add\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom functools import reduce\nfrom bisect import bisect_left, insort_left\nfrom heapq import heapify, heappush, heappop\n\nINPUT = lambda: sys.stdin.readline().rstrip()\nINT = lambda: int(INPUT())\nMAP = lambda: list(map(int, INPUT().split()))\nS_MAP = lambda: list(map(str, INPUT().split()))\nLIST = lambda: list(map(int, INPUT().split()))\nS_LIST = lambda: list(map(str, INPUT().split()))\n\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nmod = 10 ** 9 + 7\n\n\ndef main():\n    N = INT()\n    A = LIST()\n\n    if N == 2:\n        print((abs(A[1] - A[0])))\n        return\n\n    t = list(accumulate(A, add))\n    r = list(accumulate(reversed(A), add))\n\n    ans = INF\n    for i in range(N-2):\n        ans = min(ans, abs(t[i] - r[-2-i]))\n\n    print(ans)\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.35, "memory": 14160.0, "status": "done"}, {"code": "N = int(input())\na=[int(i) for i in input().split()]\n\nsum_a=sum(a)\nans = 10**11\nx=0\nfor i in range(N-1):\n    x += a[i]\n    diff = abs(sum_a - 2 * x)\n    if diff<ans:\n        ans=diff\n\n\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14084.0, "status": "done"}, {"code": "N = int(input())\na = list(map(int,input().split()))\ns = sum(a)\nsu = a[0]\nar = s - su\nans = abs(su-ar)\nfor i in range(1,N-1):\n    su += a[i]\n    ar = s - su\n    if ans > abs(su-ar):\n        ans = abs(su-ar)\nprint(ans)", "passed": true, "time": 0.15, "memory": 14204.0, "status": "done"}, {"code": "n = int(input())\nL = list(map(int,input().split()))\n\nli = [0]\n\nfor i in range(n):\n    li.append(li[i]+ L[i])\n\nsumL = sum(L)\n#print(sumL)\nans = 10**10\nfor i in range(1,n):\n    diff = abs(li[i] - (sumL - li[i]))\n    #print(diff,li[i],sumL-li[i])\n    ans = min(ans,diff)        \nprint(ans)", "passed": true, "time": 0.17, "memory": 14192.0, "status": "done"}, {"code": "import sys\nfrom itertools import accumulate\n\nsys.setrecursionlimit(10 ** 7)\ninput = sys.stdin.readline\nf_inf = float('inf')\nmod = 10 ** 9 + 7\n\n\ndef resolve():\n    n = int(input())\n    A = list(map(int, input().split()))\n\n    res = f_inf\n    R = [0] + list(accumulate(A))\n    for i in range(1, n):\n        s = R[i] - R[0]\n        a = R[-1] - R[i]\n        diff = abs(s - a)\n        res = min(res, diff)\n    print(res)\n\n\ndef __starting_point():\n    resolve()\n\n__starting_point()", "passed": true, "time": 1.88, "memory": 14056.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\nsa = sum(a) # sum a\ncs = 0 # cards sunuke\narr = []\n\nfor i in range(n-1):\n  cs += a[i]\n  ca = sa -cs #cards araiguma\n  arr.append(abs(cs-ca))\n \nprint(min(arr))", "passed": true, "time": 0.34, "memory": 14176.0, "status": "done"}, {"code": "n = int(input())\nA = list(map(int, input().split()))\n\nsum_A = [0 for _ in range(n + 1)]\nfor i in range(1, n + 1):\n    sum_A[i] = sum_A[i - 1] + A[i - 1]\n\nans = float('inf')\nfor i in range(1, n):\n    ans = min(abs(sum_A[i] - (sum_A[-1] - sum_A[i])), ans)\nprint(ans)", "passed": true, "time": 0.14, "memory": 14216.0, "status": "done"}, {"code": "from itertools import accumulate\n\nn = int(input())\nA = list(map(int, input().split()))\n\nif n == 2:\n    print(abs(A[0]-A[1]))\n    return\n\nB = list(accumulate(A))\n\nans = float(\"inf\")\ny = 0\nfor i in range(n-1, 0, -1):\n    x = B[i-1]\n    y += A[i]\n    ans = min(ans, abs(x-y))\nprint(ans)", "passed": true, "time": 0.14, "memory": 14072.0, "status": "done"}, {"code": "N = int(input())\na = list(map(int, input().split()))\ns = sum(a)\ndata = [a[0]]\nm = abs(s - 2 * a[0])\n\nfor i in range(1, N - 1):\n    data.append(a[i] + data[i - 1])\n\nfor i in range(0, N - 1):\n    if abs(s - 2 * data[i]) < m:\n        m = abs(s - 2 * data[i])\n\nprint(m)\n\n", "passed": true, "time": 0.14, "memory": 14348.0, "status": "done"}, {"code": "N=int(input())\na=list(map(int,input().split()))\ny=sum(a)\nx=0\nB=[]\nfor i in range(N-1):\n    x+=a[i]\n    y-=a[i]\n    B.append(abs(x-y))\n\nprint(min(B))", "passed": true, "time": 0.14, "memory": 14048.0, "status": "done"}, {"code": "n=int(input())\na=list(map(int,input().split()))\nsnuke=sum(a)\narai=0\nans=10**20\nfor i in range(n-1):\n    snuke-=a[i]\n    arai+=a[i]\n    ans=min(ans,abs(snuke-arai))\nprint(ans)\n", "passed": true, "time": 0.16, "memory": 14052.0, "status": "done"}, {"code": "n = int(input())\n#a, b = map(int,input().split())\nal = list(map(int, input().split()))\n#l = [list(map(int,input().split())) for i in range(n)]\n\ntotal = sum(al)\nmn = abs(total-2*al[0])\nx = 0\nfor i in range(1, n-1):\n    x += al[i-1]\n    y = total-x\n    mn = min(mn, abs(x-y))\n\nprint(mn)\n", "passed": true, "time": 0.14, "memory": 14112.0, "status": "done"}, {"code": "n=int(input());a=list(map(int,input().split()));f,b,c=0,sum(a),float('inf')\nfor i in range(n-1):\n  f,b=f+a[i],b-a[i]\n  c=min(c,abs(f-b))\nprint(c)", "passed": true, "time": 0.15, "memory": 14240.0, "status": "done"}, {"code": "n=int(input())\na=[0]+list(map(int,input().split()))\nimport itertools\na=list(itertools.accumulate(a))\nans=1e15\nfor i in range(1,n):\n    ans=min(ans,abs(a[n]-2*a[i]))\nprint(ans)", "passed": true, "time": 0.14, "memory": 14356.0, "status": "done"}, {"code": "n=int(input())\na=list(map(int,input().split()))\n\nt=sum(a)\nm=10**9\nflag=0\nfor i in range(len(a)-1):\n  t-=2*a[i]\n  if i==0:\n    m=abs(t)\n  else:\n    m=min(abs(t),m)\nprint(m)", "passed": true, "time": 0.16, "memory": 14168.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\nval = 0\nl = []\ns = sum(a)\nhlf = s/2\nfor i in range(n-1):\n    val += a[i]\n    l.append(abs(hlf - val))\n\nval = min(l)\nprint((int(val*2)))\n", "passed": true, "time": 0.14, "memory": 14068.0, "status": "done"}, {"code": "N=int(input())\na=list(map(int,input().split()))\nans=10000000000000000000\nc=0\ns=sum(a)\nfor i in range(N-1):\n    c+=a[i]\n    s-=a[i]\n    if abs(c-s)<ans:\n        ans=abs(c-s)\nprint(ans)\n", "passed": true, "time": 0.23, "memory": 14420.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int,input().split()))\nx = 0\ny = sum(a)\nans = 10**10\nfor i in range(n-1):\n    x += a[i]\n    y -= a[i]\n    ans = min(ans,abs(x-y))\nprint(ans)", "passed": true, "time": 0.14, "memory": 14256.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\n\ns = [0]*(n+1)\nfor i in range(n):\n    s[i+1] += a[i] + s[i]\n#print(s)\nans = float(\"inf\")\nfor i in range(1, n):\n    x = s[i]\n    y = s[n]-s[i]\n    ans = min(ans, abs(x-y))\nprint(ans)", "passed": true, "time": 0.23, "memory": 14088.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int,input().split()))\nsnuke = 0\narai = sum(a)\nans = 2*(10**9)\nfor i in range(n-1):\n    snuke += a[i]\n    arai -= a[i]\n    ans = min(ans,abs(snuke-arai))\nprint(ans)", "passed": true, "time": 0.14, "memory": 14236.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\nimport math\nsunuke = 0\nkuma = sum(a)\n\nmemo = abs(2*a[0] - sum(a))\nans = abs(2*a[0] - sum(a))\n\nfor i in range(n):\n    sunuke += a[i]\n    kuma -= a[i]\n    if abs(sunuke-kuma) > memo:\n        ans = memo\n    else:\n        memo = abs(sunuke-kuma)\n\nprint(ans)\n", "passed": true, "time": 0.29, "memory": 14212.0, "status": "done"}, {"code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sun Sep 27 02:27:51 2020\n\n@author: liang\n\"\"\"\n\nN = int(input())\nA = [int(x) for x in input().split()]\n\ntmp = sum(A)\ntmp -= 2*A[0]\nans = abs(tmp)\nfor i in range(1,N-1):\n    tmp -= 2*A[i]\n    ans = min(abs(tmp),abs(ans))\nprint(ans)", "passed": true, "time": 0.21, "memory": 14220.0, "status": "done"}, {"code": "#\n# abc067 c\n#\nimport sys\nfrom io import StringIO\nimport unittest\n\n\nclass TestClass(unittest.TestCase):\n    def assertIO(self, input, output):\n        stdout, stdin = sys.stdout, sys.stdin\n        sys.stdout, sys.stdin = StringIO(), StringIO(input)\n        resolve()\n        sys.stdout.seek(0)\n        out = sys.stdout.read()[:-1]\n        sys.stdout, sys.stdin = stdout, stdin\n        self.assertEqual(out, output)\n\n    def test_\u5165\u529b\u4f8b_1(self):\n        input = \"\"\"6\n1 2 3 4 5 6\"\"\"\n        output = \"\"\"1\"\"\"\n        self.assertIO(input, output)\n\n    def test_\u5165\u529b\u4f8b_2(self):\n        input = \"\"\"2\n10 -10\"\"\"\n        output = \"\"\"20\"\"\"\n        self.assertIO(input, output)\n\n\ndef resolve():\n    N = int(input())\n    A = list(map(int, input().split()))\n\n    ans = float(\"inf\")\n    S = sum(A)\n    T = []\n    T.append(A[0])\n    for i in range(1, N):\n        T.append(T[i-1]+A[i])\n\n    if N == 2:\n        ans = abs(A[0]-A[1])\n    else:\n        for i in range(1, N-1):\n            ans = min(ans, abs(S-2*T[i]))\n    print(ans)\n\n\ndef __starting_point():\n    # unittest.main()\n    resolve()\n\n__starting_point()", "passed": true, "time": 0.15, "memory": 14436.0, "status": "done"}, {"code": "#\n# abc067 c\n#\nimport sys\nfrom io import StringIO\nimport unittest\n\n\nclass TestClass(unittest.TestCase):\n    def assertIO(self, input, output):\n        stdout, stdin = sys.stdout, sys.stdin\n        sys.stdout, sys.stdin = StringIO(), StringIO(input)\n        resolve()\n        sys.stdout.seek(0)\n        out = sys.stdout.read()[:-1]\n        sys.stdout, sys.stdin = stdout, stdin\n        self.assertEqual(out, output)\n\n    def test_\u5165\u529b\u4f8b_1(self):\n        input = \"\"\"6\n1 2 3 4 5 6\"\"\"\n        output = \"\"\"1\"\"\"\n        self.assertIO(input, output)\n\n    def test_\u5165\u529b\u4f8b_2(self):\n        input = \"\"\"2\n10 -10\"\"\"\n        output = \"\"\"20\"\"\"\n        self.assertIO(input, output)\n\n\ndef resolve():\n    N = int(input())\n    A = list(map(int, input().split()))\n\n    ans = float(\"inf\")\n    S = sum(A)\n    T = []\n    T.append(A[0])\n    for i in range(1, N-1):\n        T.append(T[i-1]+A[i])\n    for t in T:\n        ans = min(ans, abs(S-2*t))\n\n    print(ans)\n\n\ndef __starting_point():\n    # unittest.main()\n    resolve()\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14620.0, "status": "done"}, {"code": "N = int(input())\na = list(map(int,input().split()))\nans = float(\"inf\")\nsnuke = 0\narai = sum(a)\nfor i in range(N-1):\n    snuke += a[i]\n    arai -= a[i]\n    ans = min(abs(snuke-arai), ans)\nprint(ans)", "passed": true, "time": 0.29, "memory": 14284.0, "status": "done"}, {"code": "from itertools import accumulate\nn = int(input())\na = list(map(int, input().split()))\na = list(accumulate(a))\nans = 10**10\nfor i in range(n-1):\n    ans = min(ans, abs(a[i]-a[-1]+a[i]))\nprint(ans)", "passed": true, "time": 0.18, "memory": 14092.0, "status": "done"}, {"code": "from itertools import accumulate\nINF = float('inf')\nN = int(input())\nA = [int(x) for x in input().split()]\n\ncumA = list(accumulate(A))\nans = INF\nfor i in range(N - 1):\n    x = cumA[i]\n    y = cumA[N - 1] - cumA[i]\n    ans = min(ans, abs(x - y))\n\nprint(ans)", "passed": true, "time": 0.25, "memory": 14228.0, "status": "done"}, {"code": "n=int(input())\na=list(map(int,input().split()))\nans=2*(10**14)+1\ns=sum(a)\nx=0\ny=s\nfor i in range(n-1):\n    x+=a[i]\n    y-=a[i]\n    ans=min(ans,abs(x-y))\nprint(ans)", "passed": true, "time": 0.27, "memory": 14040.0, "status": "done"}, {"code": "N = int(input())\na = list(map(int, input().split()))\nsa = a[:]\nfor i in range(N-1):\n  sa[i+1] += sa[i]\n\ndiff = float('inf')\nfor i in range(N-1):\n  if abs(sa[i] - (sa[-1] - sa[i])) < diff:\n    diff = abs(sa[i] - (sa[-1] - sa[i]))\n\nprint(diff)", "passed": true, "time": 0.25, "memory": 14108.0, "status": "done"}, {"code": "n=int(input())\na=list(map(int, input().split()))\ns1=sum(a)\ns2=0\nans=10**18\nfor i in range(n - 1):\n    s1-=a[i]\n    s2+=a[i]\n    ans=min(ans,abs(s1-s2))\nprint(ans)", "passed": true, "time": 0.19, "memory": 14012.0, "status": "done"}, {"code": "N=int(input())\na=list(map(int,input().strip().split()))\n#\u7d2f\u7a4d\u548c\ns_l=[]\ns=0\n\nfor n in range(N):\n    s+=a[n]\n    s_l.append(s)\n\nMIN=10**15\nfor n in range(N-1):\n    MIN=min(MIN,abs(s-s_l[n]*2))\n\nprint(MIN)", "passed": true, "time": 0.14, "memory": 14244.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int,input().split()))\n\ncumsum = [0 for _ in range(n)]\ncumsum[0] = a[0]\n\nfor i in range(1,n):\n    cumsum[i] = a[i] + cumsum[i-1]\n\nresult = [0 for _ in range(n-1)]\nlast = cumsum[-1]\n#print(last)\nfor i in range(n-1):\n    result[i] = abs(last - 2 * cumsum[i])\n\nprint((min(result)))\n\n\n\n\n", "passed": true, "time": 0.14, "memory": 14252.0, "status": "done"}, {"code": "n=int(input())\na=[int(i) for i in input().split()]\n\nsunuke=0\naraiguma=sum(a)\n\nmin_sa=100000000000000\n\nfor i in range(n-1):\n    sunuke+=a[i]\n    araiguma-=a[i]\n    min_sa=min(min_sa,abs(araiguma-sunuke))\nprint(min_sa)", "passed": true, "time": 0.14, "memory": 14048.0, "status": "done"}, {"code": "N = int(input())\nA = [int(a) for a in input().split(\" \")]\n\nsA = []\nfor i in range(len(A)):\n  if i == 0:\n    sA.append(A[0])\n  else:\n    sA.append(sA[i - 1] + A[i])\n\ns = sum(A)\ndA = [abs(2 * sA[j] - s) for j in range(len(sA) - 1)]\n\nprint(min(dA))", "passed": true, "time": 0.14, "memory": 14088.0, "status": "done"}, {"code": "from itertools import accumulate\nN = int(input())\nA = tuple(accumulate(map(int, input().split())))\nx = A[-1]\ny = A[0]\nans = abs(x - y - y)\nfor a in A[:-1]:\n    ans = min(ans, abs(x - a - a))\nprint(ans)", "passed": true, "time": 0.14, "memory": 14284.0, "status": "done"}, {"code": "N = int(input())\nlsa = list(map(int,input().split()))\nsunu = lsa[0]\nara = sum(lsa)- lsa[0]\nans = abs(ara-sunu)\nfor i in range(1,N-1):\n    sunu += lsa[i]\n    ara -= lsa[i]\n    ans = min(ans,abs(ara-sunu))\nprint(ans)", "passed": true, "time": 0.14, "memory": 14168.0, "status": "done"}, {"code": "n = int(input())\nA = list(map(int, input().split()))\n\ns = A[0]\ns_ = sum(A[1:])\ngap = abs(s-s_)\nfor i in range(1, n-1):\n    s += A[i]\n    s_ -= A[i]\n    if gap > abs(s-s_):\n        gap = abs(s-s_)\nprint(gap)", "passed": true, "time": 0.14, "memory": 14312.0, "status": "done"}, {"code": "#!/usr/bin/env python3\nimport sys\n\n\ndef solve(N: int, a: \"List[int]\"):\n    from itertools import accumulate\n    s = sum(a)\n    return min(abs(s-2*aa) for aa in accumulate(a[:-1]))\n\n# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools\ndef main():\n    def iterate_tokens():\n        for line in sys.stdin:\n            for word in line.split():\n                yield word\n    tokens = iterate_tokens()\n    N = int(next(tokens))  # type: int\n    a = [int(next(tokens)) for _ in range(N)]  # type: \"List[int]\"\n    print((solve(N, a)))\n\ndef test():\n    import doctest\n    doctest.testmod()\n\ndef __starting_point():\n    #test()\n    main()\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14144.0, "status": "done"}, {"code": "\nN=int(input())\nA=list(map(int,input().split()))\ntotal = sum(A)\narai = 0\nsunuke = 0\nans = float('inf')\n\nfor i in range(N-1):\n    sunuke += A[i]\n    arai = total - sunuke\n    ans = min(ans,abs(sunuke-arai))\n\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14088.0, "status": "done"}, {"code": "#!/usr/bin/env python\n\nn = int(input())\na = list(map(int, input().split()))\n\nl = a[0]\nr = sum(a)-l\nans = abs(l-r)\n\nfor i in range(1, n-1):\n    l += a[i]\n    r -= a[i]\n    if abs(l-r) <= ans:\n        ans = abs(l-r)\n\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14200.0, "status": "done"}, {"code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n#\n# FileName: \tC_fix\n# CreatedDate:  2020-10-10 15:17:07 +0900\n# LastModified: 2020-10-10 15:25:36 +0900\n#\n\n\nimport os\nimport sys\n# import numpy as np\n# import pandas as pd\nfrom itertools import accumulate\n\n\ndef main():\n    N = int(input())\n    A = list(map(int, input().split()))\n    A_ac = list(accumulate(A))\n    ans = A_ac[-1]\n    for i, ac in enumerate(A_ac):\n        if i == 0:\n            ans = abs(2*ac-A_ac[-1])\n        if i == N-1:\n            break\n        if abs(2*ac-A_ac[-1]) < ans:\n            ans = abs(2*ac-A_ac[-1])\n    print(ans)\n\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14232.0, "status": "done"}, {"code": "# C - Splitting Pile\ndef main():\n    n = int(input())\n    a = list(map(int, input().split()))\n    a_sum = sum(a)\n    cnt = 0\n    ans = float('inf')\n\n    for i in range(n-1):\n        cnt += a[i]\n        ans = min(ans, abs(a_sum-cnt*2))\n    else:\n        print(ans)\n\n\nif __name__ ==  \"__main__\":\n    main()", "passed": true, "time": 0.14, "memory": 14264.0, "status": "done"}, {"code": "n = int(input())\nA = list(map(int, input().split()))\n\nif n == 2:\n    print(abs(A[0]-A[1]))\n    return\n\ncum_sum = [0]\nfor a in A:\n    cum_sum.append(cum_sum[-1]+a)\n\nans = 10**9+1\nfor x in cum_sum[1:-1]:\n    y = cum_sum[-1] - x\n    ans = min(ans, abs(x-y))\nprint(ans)", "passed": true, "time": 0.14, "memory": 14252.0, "status": "done"}, {"code": "n = int(input())\na = [int(x) for x in input().split()]\ns = [0] * (n+2)\nfor i in range(n):\n  s[i+1] = s[i] + a[i]\n\nres = 10 ** 10\n\nfor i in range(1,n):\n  res = min(res,abs(s[i] - (s[n] - s[i])))\n\nprint(res)", "passed": true, "time": 0.14, "memory": 14232.0, "status": "done"}, {"code": "import math\nN = int(input())\na = list(map(int,input().split()))\n\ns = sum(a)\nt = 0\nminimum = math.inf\nfor i in range(N-1):\n    t += a[i]\n    s -= a[i]\n    minimum = min(minimum,abs(s-t))\nprint(minimum)", "passed": true, "time": 0.14, "memory": 14020.0, "status": "done"}, {"code": "a = int(input())\nb = [int(s) for s in input().split()]\nsu = sum(b) - b[a-1]\nar = b[a-1]\nans = abs(su - ar)\n\nfor i in range(2, a-1):\n  su = su - b[a-i]\n  ar = ar + b[a-i]\n  tmp = abs(su - ar)\n  if tmp < ans:\n    ans = tmp\n  tmp = 0\n\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14192.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int,input().split()))\n\nsunuke = [0] * (N)\nguma = [0] * (N)\n\nfor i in range(N-1):\n  if i == 0:\n    sunuke[i] += A[i]\n    continue  \n  sunuke[i] += sunuke[i-1] + A[i]\n\nfor j in range(N-1,0,-1):\n  if j == N - 1:\n    guma[j] += A[j]\n    continue\n  guma[j] += guma[j+1] + A[j]\n  \nans = float(\"inf\")\nfor k in range(N-1):\n  ans = min(ans, abs(sunuke[k] - guma[k+1]))\n\nprint(ans)", "passed": true, "time": 0.14, "memory": 14132.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int,input().split()))\nS = sum(A)\nT = [0]*(N+1)\nfor i in range(N):\n  T[i+1] = T[i] + A[i]\nprint(min(abs(S-2*T[i]) for i in range(1, N)))", "passed": true, "time": 0.15, "memory": 14160.0, "status": "done"}, {"code": "n = int(input())\nmain = list(map(int, input().split()))\n\ntotal = sum(main)\nbeg = 0\nfinal = float('inf')\nfor i in range(len(main) - 1):\n    beg += main[i]\n    total -= main[i]\n    final = min(final, abs(beg - total))\n\nprint(final)\n", "passed": true, "time": 0.24, "memory": 14124.0, "status": "done"}, {"code": "n=int(input())\na=list(map(int,input().split()))\nans=float(\"inf\")\nx=0\nb=sum(a)\nfor i in range(n):\n    x+=a[i]\n    if i+1<n:\n        ans=min(ans,abs(b-2*x))    \nprint(ans)", "passed": true, "time": 0.15, "memory": 14132.0, "status": "done"}, {"code": "N=int(input())\na=list(map(int,input().split()))\nl,r=a.pop(0),sum(a)\nans=10**10\nfor i in a:\n    ans=min(ans,abs(l-r))\n    l,r=l+i,r-i\nprint(ans)", "passed": true, "time": 0.25, "memory": 14152.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int,input().split()))\nS1 = A[0]\nS2 = sum(A)-A[0]\nB = [abs(S1-S2)]\n\nfor i in range(N-2):\n  S1 += A[i+1]\n  S2 -= A[i+1]\n  B.append(abs(S1-S2))\n\nprint(min(B))", "passed": true, "time": 0.16, "memory": 14024.0, "status": "done"}, {"code": "N=int(input())\n*A,=map(int,input().split())\nt=sum(A)\n\nx=0\nans=float('inf')\nfor i in range(N-1):\n    x+=A[i]\n    ans=min(ans, abs(2*x-t))\nprint(ans)", "passed": true, "time": 0.23, "memory": 14248.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\n\ns = sum(a)\n\nx = a[0]\nans = abs(x - (s - x))\nfor i in a[1:-1]:\n  ans = min(ans, abs(x - (s - x)))\n  x += i\nprint(ans)", "passed": true, "time": 0.17, "memory": 14348.0, "status": "done"}, {"code": "n=int(input())\nA=list(map(int,input().split()))\nS=sum(A)\nx=A[0]\ny=S-x\nxy_min=abs(x-y)\nfor i in range(1,n-1):\n  x+=A[i]\n  y=S-x\n  xy=abs(x-y)\n  if xy<xy_min:\n    xy_min=xy\nprint(xy_min)", "passed": true, "time": 0.14, "memory": 14200.0, "status": "done"}, {"code": "from itertools import accumulate\n\nn = int(input())\nA = list(map(int, input().split()))\nAA = list(accumulate([0] + A))\nans = 10 ** 20\nfor i in range(1, n):\n    temp1 = AA[i]\n    temp2 = AA[-1] - temp1\n    delta = abs(temp1 - temp2)\n    ans = min(delta, ans)\nprint(ans)\n", "passed": true, "time": 0.28, "memory": 14084.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\nl = []\n\ns = sum(a)\ncnt = 0\nfor i in range(n - 1):\n    cnt += a[i]\n    rem = s - cnt\n    l.append(abs(cnt - rem))\n    \nprint(min(l))", "passed": true, "time": 0.31, "memory": 14196.0, "status": "done"}, {"code": "n=int(input()) \nc=list(map(int, input().split()))\ns = sum(c)\nl = []\nx = 0\ny = s\n\nfor i in c[:n-1]:\n    x += i\n    y -= i\n    l += [abs(x-y)]\nprint(min(l))", "passed": true, "time": 0.32, "memory": 14288.0, "status": "done"}, {"code": "import math\nfrom math import gcd,pi,sqrt\nINF = float(\"inf\")\n\nimport sys\nsys.setrecursionlimit(10**6)\nimport itertools\nfrom collections import Counter,deque\ndef i_input(): return int(input())\ndef i_map(): return list(map(int, input().split()))\ndef i_list(): return list(i_map())\ndef i_row(N): return [i_input() for _ in range(N)]\ndef i_row_list(N): return [i_list() for _ in range(N)]\ndef s_input(): return input()\ndef s_map(): return input().split()\ndef s_list(): return list(s_map())\ndef s_row(N): return [s_input for _ in range(N)]\ndef s_row_str(N): return [s_list() for _ in range(N)]\ndef s_row_list(N): return [list(s_input()) for _ in range(N)]\n\nimport string\n\ndef main():\n    n = i_input()\n    a = i_list()\n\n    total = sum(a)\n\n    ans = INF\n    trial = 0\n    for i in a[:-1]:\n        trial += i\n        left = total - trial\n        ans = min(ans,abs(trial-left))\n    print(ans)\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.15, "memory": 14180.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int,input().split()))\nnums = []\ntotal = 0\nfor num in a:\n    total += num\n    nums.append(total)\nminVal = 10 ** 9 * 2 + 1\nfor i in range(n - 1):\n    sub = total - nums[i]\n    minVal = min(abs(sub - nums[i]), minVal)\nprint(minVal)", "passed": true, "time": 0.14, "memory": 14152.0, "status": "done"}, {"code": "N=int(input())\na=list(map(int,input().split()))\nsum=[0]\nfor i in range(0,N):\n    sum.append(sum[-1]+a[i])\nans=abs(sum[N]-2*sum[1])\nfor i in range(1,N):\n    ans=min(ans,abs(sum[N]-2*sum[i]))\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14136.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int,input().split()))\ny = sum(a) - a[0]\nx = a[0]\nans = abs(x-y)\nfor i in range(1,n-1):\n    x += a[i]\n    y -= a[i]\n    ans = min(ans,abs(x-y))\nprint(ans)", "passed": true, "time": 0.24, "memory": 14236.0, "status": "done"}, {"code": "# C - Splitting Pile\nN = int(input())\nA = list(map(int,input().split()))\n\ns = [0]*(N+1)\nfor i in range(N-1):\n    s[i+1] = s[i] + A[i]\n\nans = 10**10\nfor i in range(1,N):\n    diff = abs((s[N-1] + A[-1] - s[i]) - s[i])\n    ans = min(ans,diff)\nprint(ans)", "passed": true, "time": 0.14, "memory": 14096.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\nsum_a = sum(a)\nres = 10 ** 10\ntmp_sum = 0\nfor i in range(n - 1):\n    tmp_sum += a[i]\n    res = min(res, abs(tmp_sum - (sum_a - tmp_sum)))\n\nprint(res)\n", "passed": true, "time": 0.14, "memory": 14216.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int, input().split()))\n\ns = A[0]\na = sum(A[1:])\n\nans = abs(s - a)\n\nfor i in range(1, N-1):\n  s += A[i]\n  a -= A[i]\n  ans = min(ans, abs(s - a))\n\nprint(ans)", "passed": true, "time": 0.15, "memory": 14304.0, "status": "done"}, {"code": "n=int(input())\na=list(map(int,input().split()))\n\nrui=[]\nrui.append(a[0])\nfor x in range(1,n):\n  b=rui[-1]+a[x]\n  rui.append(b)\n\nans=[]\nfor y in range(n-1):\n  ans.append(abs((rui[n-1]-rui[y])-rui[y]))\n  \nprint(min(ans))", "passed": true, "time": 0.14, "memory": 14196.0, "status": "done"}, {"code": "import itertools\nn = int(input())\na = list(map(int, input().split()))\n\nn_acc = itertools.accumulate(a)\n#r_acc = itertools.accumulate(a[::-1])\n# 1, 3, 6, 10, 15 ,21\n# 1 vs 20\n# 3 vs\n#print(n_acc, r_acc)\n\n\nsigma = sum(a)\nans = 10 ** 16\n\nfor i, val in enumerate(n_acc):\n    if (i == len(a) - 1):\n        break\n\n    rest = sigma - val\n    ans = min(abs(val - rest), ans)\n\n\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14100.0, "status": "done"}, {"code": "\n\n\n\n\n\n\n\n\n#!/usr/bin/env python3\n\n# from numba import njit\n\n# input = stdin.readline\nINF = pow(10,10)\n# @njit\ndef solve(n,a):\n  res = INF\n  x = 0\n  y = sum(a)\n  for i in range(n-1):\n    x += a[i]\n    y -= a[i]\n    res = min(res,abs(x-y))\n  return res\n\n\n\ndef main():\n  N = int(input())\n  # N,M = map(int,input().split())\n  a = list(map(int,input().split()))\n  print((solve(N,a)))\n  return\n\ndef __starting_point():\n  main()\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14220.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\n\ns = sum(a)\nx = 0\nans = abs(2 * a[0] - s)\nsnuke = a[0]\n\nfor i in range(1, n-1):\n    snuke += a[i]\n    if abs(2 * snuke - s) < ans:\n        ans = abs(2 * snuke - s)\n\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14104.0, "status": "done"}, {"code": "n=int(input())\na=list(map(int,input().split()))\nb=[]\nc=[]\ns=sum(a)\nt=0\nfor i in range(n-1):\n    b.append(t+a[i])\n    t=b[i]\nfor i in range(n-1):\n    c.append(abs(2*b[i]-s))\nc.sort()\nprint(c[0])", "passed": true, "time": 0.14, "memory": 14292.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int,input().split()))\ns = sum(a)\ntemp,ans = 0,float('inf')\nfor v in a[:-1]:\n  temp += v\n  s -= v\n  ans = min(ans,abs(temp-s))\nprint(ans)", "passed": true, "time": 0.14, "memory": 14248.0, "status": "done"}, {"code": "n = int(input())\nal = list(map(int, input().split()))\nbl = [0]*(n+1)\ncl = [0]*(n-1)\n\nfor i in range(n):\n    bl[i+1] = al[i] + bl[i]\n\nfor j in range(1, n):\n    cl[j-1] = abs(bl[j] - (bl[n] - bl[j]))\n\nprint(min(cl))", "passed": true, "time": 0.14, "memory": 14328.0, "status": "done"}, {"code": "n=int(input())\na=list(map(int,input().split()))\nsm=sum(a)\ns=a.pop(0)\nmn=abs(sm-s*2)\nfor i in a[:-1]:\n  s+=i\n  mn=min(mn,abs(sm-s*2))\n  \nprint(mn)", "passed": true, "time": 0.15, "memory": 14180.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int,input().split()))\nasum = [0]*(n+1)\n\nfor i in range(n):\n    asum[i+1] = asum[i] + a[i]\n\nans = 10**12\nfor i in range(1,n):\n    snu = asum[i]\n    arai = asum[-1] - asum[i]\n    ans_ = abs(snu - arai)\n    if ans >ans_:\n        ans = ans_\n        \nprint(ans)", "passed": true, "time": 0.14, "memory": 14100.0, "status": "done"}, {"code": "n = int(input())\narr = list(map(int, input().split()))\nsum1 = 0\nsum2 = sum(arr)\nmin_ = 1<<60\n\nfor i in range(n-1):\n    sum1 += arr[i]\n    sum2 -= arr[i]\n    min_ = min(min_, abs(sum1 - sum2))\nprint(min_)", "passed": true, "time": 0.14, "memory": 14052.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int,input().split()))\n\ns = a[0]\nt = sum(a) - a[0]\n\ni = 0\nans = abs(s - t)\nfor i in range(1, n-1):\n    s += a[i]\n    t -= a[i]\n    ans = min(ans, abs(s - t))\n    i += 1\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14324.0, "status": "done"}, {"code": "N=int(input())\na=list(map(int,input().split()))\n\ncum=[0]\nfor i in range(N):\n  cum.append(cum[-1]+a[i])\n  \nans=10**20\nfor i in range(1,N):\n  tmp = abs(cum[-1]-cum[i]-cum[i])\n  ans = min(ans, tmp)\n  \nprint(ans)", "passed": true, "time": 0.14, "memory": 14296.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int,input().split()))\nli = [a[0]]\nfor i in range(n-1):\n    li.append(li[i]+a[i+1])\n\nb = []\nfor i in range(n-1):\n    b.append(abs(li[-1]-li[i]*2))\nprint(min(b))", "passed": true, "time": 0.15, "memory": 14296.0, "status": "done"}, {"code": "n=int(input())\na=list(map(int,input().split()))\nb=[a[0]]\nfor i in range(1,n):\n    b.append(b[-1]+a[i])\ns=sum(a)\nans=10**20\nfor i in range(n-1):\n    ans=min(ans,abs(s-2*b[i]))\nprint(ans)\n", "passed": true, "time": 0.15, "memory": 14196.0, "status": "done"}, {"code": "N=int(input())\nL=list(map(int,input().split()))\nsums=0\na=sum(L)\nmina=10**10\nfor i in range(N-1):\n  a-=2*L[i]\n  mina=min(mina,abs(a))\nprint(mina)", "passed": true, "time": 0.14, "memory": 14116.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\n\nsa = [0 for i in range(n)]\nsc = sum(a)\nc = 0\nfor i in range(n):\n  c += a[i]\n  sa[i] = c\nans = 10**10\n\nfor i in range(1,n):\n  x = sc-sa[i-1]\n  v = abs(x-sa[i-1])\n  ans = min(ans,v)\nprint (ans)\n", "passed": true, "time": 0.14, "memory": 14200.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int, input().split()))\nx = A[0]\ny = sum(A[1:])\nans = abs(x - y)\nfor i in range(1, N - 1):\n    a = A[i]\n    x += a\n    y -= a\n    dif = abs(x - y)\n    if dif < ans:\n        ans = dif\nprint(ans)", "passed": true, "time": 0.14, "memory": 14060.0, "status": "done"}, {"code": "n=int(input())\na=[int(x) for x in input().rstrip().split()]\n\nruiseki=[0]\nfor i in range(n):\n  ruiseki.append(ruiseki[i]+a[i])\n\nans=float('inf')\nlast=ruiseki[len(ruiseki)-1]\n# print(last)\n# print(ruiseki)\nfor i in range(1,len(ruiseki)-1):\n  now=(last-ruiseki[i])\n  ans=min(ans,abs(ruiseki[i]-now))\nprint(ans)\n  \n\n\n", "passed": true, "time": 0.14, "memory": 14104.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int,input().split()))\n\nS = sum(A)\n\nsnk = 0\narigm = S\n\nans = 1e20\n\nfor i in range(N-1):\n  snk += A[i]\n  arigm -= A[i]\n  #print(snk,arigm)\n  ans = min(abs(snk-arigm),ans)\nprint(ans)", "passed": true, "time": 0.14, "memory": 14292.0, "status": "done"}]