import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    N, *W = map(int, read().split())

    ans = INF
    for t in range(1, N):
        ans = min(ans, abs(sum(W[:t]) - sum(W[t:])))

    print(ans)
    return


if __name__ == '__main__':
    main() import sys sys read = sys.stdin.read read sys.stdin.read sys.stdin sys stdin read readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline readlines = sys.stdin.readlines readlines sys.stdin.readlines sys.stdin sys stdin readlines sys.setrecursionlimit(10 ** 9) sys.setrecursionlimit sys setrecursionlimit 10 ** 9 10 9 INF = 1 << 60 INF 1 << 60 1 60 def main():
    N, *W = map(int, read().split())

    ans = INF
    for t in range(1, N):
        ans = min(ans, abs(sum(W[:t]) - sum(W[t:])))

    print(ans)
    return main N, *W = map(int, read().split()) N map(int, read().split()) map int read().split() ().split () read split *W W ans = INF ans INF for t in range(1, N):
        ans = min(ans, abs(sum(W[:t]) - sum(W[t:])))

     t range(1, N) range 1 N ans = min(ans, abs(sum(W[:t]) - sum(W[t:]))) ans min(ans, abs(sum(W[:t]) - sum(W[t:]))) min ans abs(sum(W[:t]) - sum(W[t:])) abs sum(W[:t]) - sum(W[t:]) sum(W[:t]) sum W[:t] W :t t sum(W[t:]) sum W[t:] W t: t print(ans) print ans return if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main readline = sys.stdin.readline sys.stdin.readline readline readlines = sys.stdin.readlines sys.stdin.readlines readlines INF = 1 << 60 1 << 60 INF def main():
    N, *W = map(int, read().split())

    ans = INF
    for t in range(1, N):
        ans = min(ans, abs(sum(W[:t]) - sum(W[t:])))

    print(ans)
    return def main():
    N, *W = map(int, read().split())

    ans = INF
    for t in range(1, N):
        ans = min(ans, abs(sum(W[:t]) - sum(W[t:])))

    print(ans)
    return main read = sys.stdin.read sys.stdin.read read
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    N, *W = map(int, read().split())

    ans = INF
    for t in range(1, N):
        ans = min(ans, abs(sum(W[:t]) - sum(W[t:])))

    print(ans)
    return


if __name__ == '__main__':
    main()
