import std.stdio, std.string, std.conv, std.algorithm, std.math;

void main() {
    int n = readln.chomp.to!int;
    int[] w = readln.split.to!(int[]);
    int l, r = w.sum;
    int diff = r;
    foreach (i; 0 .. n) {
        l += w[i];
        r -= w[i];
        if (abs(l-r) > diff) break;
        diff = abs(l-r);
    }
    diff.writeln;
}