n = int(input())
w = [int(x) for x in input().split()]

t = int(n/2)
s1 = sum(w[0:t])
s2 = sum(w[t:n])

if s1 == s2:print(0)
else:
    if s1<s2: a=1
    if s1>s2: a=-1
    out = abs(s1-s2)

    for xi in range(n):
        t = t+a
        if a == 1:
            s1 += w[t-1]
            s2 -= w[t-1]
        if a ==-1:
            s1 -= w[t]
            s2 += w[t]
        if out<abs(s1-s2):break
        out = abs(s1-s2)

print(out) n = int(input()) n int(input()) int input() input int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x w = [int(x) for x in input().split()] w [int(x) for x in input().split()] t = int(n/2) t int(n/2) int n/2 n 2 s1 = sum(w[0:t]) s1 sum(w[0:t]) sum w[0:t] w 0:t 0 t s2 = sum(w[t:n]) s2 sum(w[t:n]) sum w[t:n] w t:n t n if s1 == s2:print(0)
else:
    if s1<s2: a=1
    if s1>s2: a=-1
    out = abs(s1-s2)

    for xi in range(n):
        t = t+a
        if a == 1:
            s1 += w[t-1]
            s2 -= w[t-1]
        if a ==-1:
            s1 -= w[t]
            s2 += w[t]
        if out<abs(s1-s2):break
        out = abs(s1-s2) s1 == s2 s1 s2 if s1<s2: a=1
     s1<s2 s1 s2 if s1>s2: a=-1
     s1>s2 s1 s2 out = abs(s1-s2) out abs(s1-s2) abs s1-s2 s1 s2 for xi in range(n):
        t = t+a
        if a == 1:
            s1 += w[t-1]
            s2 -= w[t-1]
        if a ==-1:
            s1 -= w[t]
            s2 += w[t]
        if out<abs(s1-s2):break
        out = abs(s1-s2) xi range(n) range n t = t+a t t+a t a if a == 1:
            s1 += w[t-1]
            s2 -= w[t-1]
         a == 1 a 1 s1 += w[t-1] s1 w[t-1] w t-1 t 1 s2 -= w[t-1] s2 w[t-1] w t-1 t 1 if a ==-1:
            s1 -= w[t]
            s2 += w[t]
         a ==-1 a -1 s1 -= w[t] s1 w[t] w t s2 += w[t] s2 w[t] w t if out<abs(s1-s2):break
         out<abs(s1-s2) out abs(s1-s2) abs s1-s2 s1 s2 out = abs(s1-s2) out abs(s1-s2) abs s1-s2 s1 s2 print(out) print out w = [int(x) for x in input().split()] [int(x) for x in input().split()] w s2 += w[t] w[t] s2 out = abs(s1-s2) abs(s1-s2) out t = t+a t+a t t = int(n/2) int(n/2) t s2 = sum(w[t:n]) sum(w[t:n]) s2 s2 -= w[t-1] w[t-1] s2 n = int(input()) int(input()) n out = abs(s1-s2) abs(s1-s2) out s1 += w[t-1] w[t-1] s1 s1 = sum(w[0:t]) sum(w[0:t]) s1 s1 -= w[t] w[t] s1
n = int(input())
w = [int(x) for x in input().split()]

t = int(n/2)
s1 = sum(w[0:t])
s2 = sum(w[t:n])

if s1 == s2:print(0)
else:
    if s1<s2: a=1
    if s1>s2: a=-1
    out = abs(s1-s2)

    for xi in range(n):
        t = t+a
        if a == 1:
            s1 += w[t-1]
            s2 -= w[t-1]
        if a ==-1:
            s1 -= w[t]
            s2 += w[t]
        if out<abs(s1-s2):break
        out = abs(s1-s2)

print(out)
