import std.stdio, std.conv, std.string, std.math, std.regex, std.range, std.ascii, std.algorithm;

void main(){
	auto N = readln.chomp.to!long;
	auto W = readln.split.to!(long[]);
	long count = W.sum;
	foreach(i; 0..N){
		long x = abs(W.sum - 2*((W[0..i]).sum));
		if(x < count) count=x;
	}
	writeln(count);
}