def main():
    N = int(input())
    w = list(map(int, input().split()))
    record = []
    t = 0
    for i in range(1, N):
        t = t + w[i-1]
        record.append(abs(t - sum(w[i:N])))
    record.sort()
    print(record[0])
main()   def main():
    N = int(input())
    w = list(map(int, input().split()))
    record = []
    t = 0
    for i in range(1, N):
        t = t + w[i-1]
        record.append(abs(t - sum(w[i:N])))
    record.sort()
    print(record[0]) main N = int(input()) N int(input()) int input() input w = list(map(int, input().split())) w list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split record = [] record [] t = 0 t 0 for i in range(1, N):
        t = t + w[i-1]
        record.append(abs(t - sum(w[i:N])))
     i range(1, N) range 1 N t = t + w[i-1] t t + w[i-1] t w[i-1] w i-1 i 1 record.append(abs(t - sum(w[i:N]))) record.append record append abs(t - sum(w[i:N])) abs t - sum(w[i:N]) t sum(w[i:N]) sum w[i:N] w i:N i N record.sort() record.sort record sort print(record[0]) print record[0] record 0 main() main def main():
    N = int(input())
    w = list(map(int, input().split()))
    record = []
    t = 0
    for i in range(1, N):
        t = t + w[i-1]
        record.append(abs(t - sum(w[i:N])))
    record.sort()
    print(record[0]) def main():
    N = int(input())
    w = list(map(int, input().split()))
    record = []
    t = 0
    for i in range(1, N):
        t = t + w[i-1]
        record.append(abs(t - sum(w[i:N])))
    record.sort()
    print(record[0]) main
def main():
    N = int(input())
    w = list(map(int, input().split()))
    record = []
    t = 0
    for i in range(1, N):
        t = t + w[i-1]
        record.append(abs(t - sum(w[i:N])))
    record.sort()
    print(record[0])
main()  