#create date: 2020-07-25 09:13

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    w = na()
    l, r = 0, sum(w)
    ans = 10**10
    for i in range(0, n-1):
        l += w[i]
        r -= w[i]
        ans = min(ans, abs(l - r))
    print(ans)

if __name__ == "__main__":
    main() import sys sys stdin = sys.stdin stdin sys.stdin sys stdin def ns(): return stdin.readline().rstrip() ns def ni(): return int(ns()) ni def na(): return list(map(int, stdin.readline().split())) na def main():
    n = ni()
    w = na()
    l, r = 0, sum(w)
    ans = 10**10
    for i in range(0, n-1):
        l += w[i]
        r -= w[i]
        ans = min(ans, abs(l - r))
    print(ans) main n = ni() n ni() ni w = na() w na() na l, r = 0, sum(w) l 0 r sum(w) sum w ans = 10**10 ans 10**10 10 10 for i in range(0, n-1):
        l += w[i]
        r -= w[i]
        ans = min(ans, abs(l - r))
     i range(0, n-1) range 0 n-1 n 1 l += w[i] l w[i] w i r -= w[i] r w[i] w i ans = min(ans, abs(l - r)) ans min(ans, abs(l - r)) min ans abs(l - r) abs l - r l r print(ans) print ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def na(): return list(map(int, stdin.readline().split())) def na(): return list(map(int, stdin.readline().split())) na stdin = sys.stdin sys.stdin stdin def ns(): return stdin.readline().rstrip() def ns(): return stdin.readline().rstrip() ns def ni(): return int(ns()) def ni(): return int(ns()) ni def main():
    n = ni()
    w = na()
    l, r = 0, sum(w)
    ans = 10**10
    for i in range(0, n-1):
        l += w[i]
        r -= w[i]
        ans = min(ans, abs(l - r))
    print(ans) def main():
    n = ni()
    w = na()
    l, r = 0, sum(w)
    ans = 10**10
    for i in range(0, n-1):
        l += w[i]
        r -= w[i]
        ans = min(ans, abs(l - r))
    print(ans) main
#create date: 2020-07-25 09:13

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    w = na()
    l, r = 0, sum(w)
    ans = 10**10
    for i in range(0, n-1):
        l += w[i]
        r -= w[i]
        ans = min(ans, abs(l - r))
    print(ans)

if __name__ == "__main__":
    main()