import sys
import math
import itertools as it
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n = I()
    w = Intl()
    s = w[0]
    ans = float("inf")
    for i in range(1,n):
        s += w[i]
        ans = min(ans,abs(2*s-sum(w)))
    print(ans) import sys sys import math math import itertools as it itertools def I():return int(sys.stdin.readline().replace("\n","")) I def I2():return map(int,sys.stdin.readline().replace("\n","").split()) I2 def S():return str(sys.stdin.readline().replace("\n","")) S def L():return list(sys.stdin.readline().replace("\n","")) L int(k) for k in sys.stdin.readline().replace("\n","").split() for k in sys.stdin.readline().replace("\n","").split() k sys.stdin.readline().replace("\n","").split() sys.stdin.readline().replace("\n","").split sys.stdin.readline().replace("\n","") sys.stdin.readline().replace sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline replace "\n" "" split for k in sys.stdin.readline().replace("\n","").split() int(k) int k def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()] Intl def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split())) Lx k k if __name__ == "__main__":
    n = I()
    w = Intl()
    s = w[0]
    ans = float("inf")
    for i in range(1,n):
        s += w[i]
        ans = min(ans,abs(2*s-sum(w)))
    print(ans) __name__ == "__main__" __name__ "__main__" n = I() n I() I w = Intl() w Intl() Intl s = w[0] s w[0] w 0 ans = float("inf") ans float("inf") float "inf" for i in range(1,n):
        s += w[i]
        ans = min(ans,abs(2*s-sum(w)))
     i range(1,n) range 1 n s += w[i] s w[i] w i ans = min(ans,abs(2*s-sum(w))) ans min(ans,abs(2*s-sum(w))) min ans abs(2*s-sum(w)) abs 2*s-sum(w) 2*s 2 s sum(w) sum w print(ans) print ans s = w[0] w[0] s def L():return list(sys.stdin.readline().replace("\n","")) def L():return list(sys.stdin.readline().replace("\n","")) L s += w[i] w[i] s def I2():return map(int,sys.stdin.readline().replace("\n","").split()) def I2():return map(int,sys.stdin.readline().replace("\n","").split()) I2 def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()] def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()] Intl ans = float("inf") float("inf") ans ans = min(ans,abs(2*s-sum(w))) min(ans,abs(2*s-sum(w))) ans def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split())) def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split())) Lx def S():return str(sys.stdin.readline().replace("\n","")) def S():return str(sys.stdin.readline().replace("\n","")) S w = Intl() Intl() w n = I() I() n def I():return int(sys.stdin.readline().replace("\n","")) def I():return int(sys.stdin.readline().replace("\n","")) I
import sys
import math
import itertools as it
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n = I()
    w = Intl()
    s = w[0]
    ans = float("inf")
    for i in range(1,n):
        s += w[i]
        ans = min(ans,abs(2*s-sum(w)))
    print(ans)