import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
T Read(T)() { return readln.chomp.to!(T); }
T[] Reads(T)() { return readln.split.to!(T[]); }
alias read = Read!(int);
alias reads = Reads!(int);

void main() {
    int n = read();
    int[] a = reads();
    int ans = int.max;
    foreach (i; 1..n) {
        int d = abs(a[0..i].sum - a[i..$].sum);
        ans = min(ans, d);
    }
    writeln(ans);
}