import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n = I()
w = LI()
t = float('inf')
s_1 = 0
s_2 = sum(w)
for i in range(n):
    s_1 += w[i]
    s_2 -= w[i]
    t = min(t, abs(s_1 - s_2))
print(t) import sys sys def input(): return sys.stdin.readline().strip() input def I(): return int(input()) I def LI(): return list(map(int, input().split())) LI I() for i in range(n) for i in range(n) i range(n) range n for i in range(n) I() I def IR(n): return [I() for i in range(n)] IR n n LI() for i in range(n) for i in range(n) i range(n) range n for i in range(n) LI() LI def LIR(n): return [LI() for i in range(n)] LIR n n S() for i in range(n) for i in range(n) i range(n) range n for i in range(n) S() S def SR(n): return [S() for i in range(n)] SR n n def S(): return input() S def LS(): return input().split() LS INF = float('inf') INF float('inf') float 'inf' n = I() n I() I w = LI() w LI() LI t = float('inf') t float('inf') float 'inf' s_1 = 0 s_1 0 s_2 = sum(w) s_2 sum(w) sum w for i in range(n):
    s_1 += w[i]
    s_2 -= w[i]
    t = min(t, abs(s_1 - s_2)) i range(n) range n s_1 += w[i] s_1 w[i] w i s_2 -= w[i] s_2 w[i] w i t = min(t, abs(s_1 - s_2)) t min(t, abs(s_1 - s_2)) min t abs(s_1 - s_2) abs s_1 - s_2 s_1 s_2 print(t) print t def LI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) LI def S(): return input() def S(): return input() S def LS(): return input().split() def LS(): return input().split() LS INF = float('inf') float('inf') INF def input(): return sys.stdin.readline().strip() def input(): return sys.stdin.readline().strip() input def I(): return int(input()) def I(): return int(input()) I w = LI() LI() w t = float('inf') float('inf') t s_1 = 0 0 s_1 def LIR(n): return [LI() for i in range(n)] def LIR(n): return [LI() for i in range(n)] LIR def SR(n): return [S() for i in range(n)] def SR(n): return [S() for i in range(n)] SR s_2 -= w[i] w[i] s_2 s_2 = sum(w) sum(w) s_2 def IR(n): return [I() for i in range(n)] def IR(n): return [I() for i in range(n)] IR s_1 += w[i] w[i] s_1 t = min(t, abs(s_1 - s_2)) min(t, abs(s_1 - s_2)) t n = I() I() n
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n = I()
w = LI()
t = float('inf')
s_1 = 0
s_2 = sum(w)
for i in range(n):
    s_1 += w[i]
    s_2 -= w[i]
    t = min(t, abs(s_1 - s_2))
print(t)
