import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    W = [int(w) for w in input().split()]
    wt = [0] * (N + 1)
    for i, w in enumerate(W):
        wt[i+1] = wt[i] + w
    minD = 1000000
    for i in range(N):
        minD = min(minD, abs(wt[i+1] - (wt[N] - wt[i+1])))
    print(minD)

    return 0

if __name__ == "__main__":
    solve() import sys sys def solve():
    input = sys.stdin.readline
    N = int(input())
    W = [int(w) for w in input().split()]
    wt = [0] * (N + 1)
    for i, w in enumerate(W):
        wt[i+1] = wt[i] + w
    minD = 1000000
    for i in range(N):
        minD = min(minD, abs(wt[i+1] - (wt[N] - wt[i+1])))
    print(minD)

    return 0 solve input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline N = int(input()) N int(input()) int input() input int(w) for w in input().split() for w in input().split() w input().split() ().split () input split for w in input().split() int(w) int w W = [int(w) for w in input().split()] W [int(w) for w in input().split()] wt = [0] * (N + 1) wt [0] * (N + 1) [0] 0 N + 1 N 1 for i, w in enumerate(W):
        wt[i+1] = wt[i] + w
     i w enumerate(W) enumerate W wt[i+1] = wt[i] + w wt[i+1] wt i+1 i 1 wt[i] + w wt[i] wt i w minD = 1000000 minD 1000000 for i in range(N):
        minD = min(minD, abs(wt[i+1] - (wt[N] - wt[i+1])))
     i range(N) range N minD = min(minD, abs(wt[i+1] - (wt[N] - wt[i+1]))) minD min(minD, abs(wt[i+1] - (wt[N] - wt[i+1]))) min minD abs(wt[i+1] - (wt[N] - wt[i+1])) abs wt[i+1] - (wt[N] - wt[i+1]) wt[i+1] wt i+1 i 1 wt[N] - wt[i+1] wt[N] wt N wt[i+1] wt i+1 i 1 print(minD) print minD return 0 0 if __name__ == "__main__":
    solve() __name__ == "__main__" __name__ "__main__" solve() solve def solve():
    input = sys.stdin.readline
    N = int(input())
    W = [int(w) for w in input().split()]
    wt = [0] * (N + 1)
    for i, w in enumerate(W):
        wt[i+1] = wt[i] + w
    minD = 1000000
    for i in range(N):
        minD = min(minD, abs(wt[i+1] - (wt[N] - wt[i+1])))
    print(minD)

    return 0 def solve():
    input = sys.stdin.readline
    N = int(input())
    W = [int(w) for w in input().split()]
    wt = [0] * (N + 1)
    for i, w in enumerate(W):
        wt[i+1] = wt[i] + w
    minD = 1000000
    for i in range(N):
        minD = min(minD, abs(wt[i+1] - (wt[N] - wt[i+1])))
    print(minD)

    return 0 solve
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    W = [int(w) for w in input().split()]
    wt = [0] * (N + 1)
    for i, w in enumerate(W):
        wt[i+1] = wt[i] + w
    minD = 1000000
    for i in range(N):
        minD = min(minD, abs(wt[i+1] - (wt[N] - wt[i+1])))
    print(minD)

    return 0

if __name__ == "__main__":
    solve()