n = int(input())
w = [int(i) for i in input().split()]
d = sum(w)
for wi in w:
    if d - 2 * wi < 0:
        print(min(d, 2 * wi - d))
        break
    d -= 2 * wi n = int(input()) n int(input()) int input() input int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i w = [int(i) for i in input().split()] w [int(i) for i in input().split()] d = sum(w) d sum(w) sum w for wi in w:
    if d - 2 * wi < 0:
        print(min(d, 2 * wi - d))
        break
    d -= 2 * wi wi w if d - 2 * wi < 0:
        print(min(d, 2 * wi - d))
        break
     d - 2 * wi < 0 d - 2 * wi d 2 * wi 2 wi 0 print(min(d, 2 * wi - d)) print min(d, 2 * wi - d) min d 2 * wi - d 2 * wi 2 wi d break d -= 2 * wi d 2 * wi 2 wi n = int(input()) int(input()) n d = sum(w) sum(w) d w = [int(i) for i in input().split()] [int(i) for i in input().split()] w d -= 2 * wi 2 * wi d
n = int(input())
w = [int(i) for i in input().split()]
d = sum(w)
for wi in w:
    if d - 2 * wi < 0:
        print(min(d, 2 * wi - d))
        break
    d -= 2 * wi
