import numpy as np



num = int(eval(input()))

inputs = np.array(input().split(), dtype=np.int32)



left = 0

right = len(inputs)-1

diff = 0



while left <= right:

    if diff == 0:

        diff += inputs[left] - inputs[right]

        left += 1

        right -= 1

    elif diff < 0:

        diff += inputs[left]

        left += 1

    elif diff > 0:

        diff -= inputs[right]

        right -= 1



print((np.abs(diff)))
import numpy as np



N = int(eval(input()))

inputs = np.array(input().split(), dtype=np.uint8)



total = inputs.sum()

s1 = 0

diffs = []



for t in range(N):

    s1 += inputs[t]

    s2 = total - s1

    diff = np.abs(s1-s2)

    diffs.append(int(diff))



print((np.min(diffs)))
import numpy as np

num = int(eval(input()))
inputs = np.array(input().split(), dtype=np.int32)
left = 0
right = len(inputs) - 1
diff = 0
while left <= right:
    if diff == 0:
        diff += inputs[left] - inputs[right]
        left += 1
        right -= 1
    elif diff < 0:
        diff += inputs[left]
        left += 1
    elif diff > 0:
        diff -= inputs[right]
        right -= 1
print((np.abs(diff)))

import numpy as np

N = int(eval(input()))
inputs = np.array(input().split(), dtype=np.uint8)
total = inputs.sum()
s1 = 0
diffs = []
for t in range(N):
    s1 += inputs[t]
    s2 = total - s1
    diff = np.abs(s1 - s2)
    diffs.append(int(diff))
print((np.min(diffs)))

-num = int(eval(input())) -inputs = np.array(input().split(), dtype=np.int32) -left = 0 -right = len(inputs) - 1 -diff = 0 -while left <= right: -    if diff == 0: -        diff += inputs[left] - inputs[right] -        left += 1 -        right -= 1 -    elif diff < 0: -        diff += inputs[left] -        left += 1 -    elif diff > 0: -        diff -= inputs[right] -        right -= 1 -print((np.abs(diff))) +N = int(eval(input())) +inputs = np.array(input().split(), dtype=np.uint8) +total = inputs.sum() +s1 = 0 +diffs = [] +for t in range(N): +    s1 += inputs[t] +    s2 = total - s1 +    diff = np.abs(s1 - s2) +    diffs.append(int(diff)) +print((np.min(diffs)))