import numpy as np

n = int(eval(input()))

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

ans = 0



s = sum(a)



a_ = np.cumsum(a)

diff = []

for i in range(n):

        diff.append(abs(a_[i] - (s - a_[i])))

print((min(diff)))
n = int(eval(input()))

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

ans = 0

s = sum(a)

al = []



sum1 = 0



for i in range(0,n):

        # if i == 1:

        #         sum1 = sum(a[0:i])

        # else:

        #         sum1 += a[i]

        sum1 += a[i]

        sum2 = s - sum1

        # print("sum1:"+str(sum1))

        # print("sum2:"+str(sum2))

        al.append(abs(sum1 - sum2))

        if sum1 == sum2:

                print((0))

                exit()



minDiffIdx = al.index(min(al))



# print("---")

# print(minDiffIdx)

# print("---")



tmp1 = sum(a[0:minDiffIdx])

tmp2 = sum(a[minDiffIdx:])

# print(tmp1)

# print(tmp2)

diff1 = abs(tmp1 - tmp2)



tmp3 = sum(a[0:minDiffIdx + 1])

tmp4 = sum(a[minDiffIdx + 1:])

# print(tmp3)

# print(tmp4)

diff2 = abs(tmp3 - tmp4)

print((min(diff1, diff2)))



# d1 = diff1

# d2 = diff2



# if d1 < d2:

#         for i in range(n//2):

#                 if a[i] > 1:

#                         d1 -= a[i]

#                 if d1 < 0:

#                         ans += diff1 + d1

#                         break

#                 elif d1 == 0:

#                         ans += diff1

#                         break

#         if 

# else:

import numpy as np

n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
s = sum(a)
a_ = np.cumsum(a)
diff = []
for i in range(n):
    diff.append(abs(a_[i] - (s - a_[i])))
print((min(diff)))

n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
s = sum(a)
al = []
sum1 = 0
for i in range(0, n):
    # if i == 1:
    #         sum1 = sum(a[0:i])
    # else:
    #         sum1 += a[i]
    sum1 += a[i]
    sum2 = s - sum1
    # print("sum1:"+str(sum1))
    # print("sum2:"+str(sum2))
    al.append(abs(sum1 - sum2))
    if sum1 == sum2:
        print((0))
        exit()
minDiffIdx = al.index(min(al))
# print("---")
# print(minDiffIdx)
# print("---")
tmp1 = sum(a[0:minDiffIdx])
tmp2 = sum(a[minDiffIdx:])
# print(tmp1)
# print(tmp2)
diff1 = abs(tmp1 - tmp2)
tmp3 = sum(a[0 : minDiffIdx + 1])
tmp4 = sum(a[minDiffIdx + 1 :])
# print(tmp3)
# print(tmp4)
diff2 = abs(tmp3 - tmp4)
print((min(diff1, diff2)))
# d1 = diff1
# d2 = diff2
# if d1 < d2:
#         for i in range(n//2):
#                 if a[i] > 1:
#                         d1 -= a[i]
#                 if d1 < 0:
#                         ans += diff1 + d1
#                         break
#                 elif d1 == 0:
#                         ans += diff1
#                         break
#         if
# else:

-import numpy as np - -a_ = np.cumsum(a) -diff = [] -for i in range(n): -    diff.append(abs(a_[i] - (s - a_[i]))) -print((min(diff))) +al = [] +sum1 = 0 +for i in range(0, n): +    # if i == 1: +    #         sum1 = sum(a[0:i]) +    # else: +    #         sum1 += a[i] +    sum1 += a[i] +    sum2 = s - sum1 +    # print("sum1:"+str(sum1)) +    # print("sum2:"+str(sum2)) +    al.append(abs(sum1 - sum2)) +    if sum1 == sum2: +        print((0)) +        exit() +minDiffIdx = al.index(min(al)) +# print(minDiffIdx) +tmp1 = sum(a[0:minDiffIdx]) +tmp2 = sum(a[minDiffIdx:]) +# print(tmp1) +# print(tmp2) +diff1 = abs(tmp1 - tmp2) +tmp3 = sum(a[0 : minDiffIdx + 1]) +tmp4 = sum(a[minDiffIdx + 1 :]) +# print(tmp3) +# print(tmp4) +diff2 = abs(tmp3 - tmp4) +print((min(diff1, diff2))) +# d1 = diff1 +# d2 = diff2 +# if d1 < d2: +#         for i in range(n//2): +#                 if a[i] > 1: +#                         d1 -= a[i] +#                 if d1 < 0: +#                         ans += diff1 + d1 +#                         break +#                 elif d1 == 0: +#                         ans += diff1 +#                         break +#         if +# else: