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

T readNum(T)(){
  return readStr.to!T;
}

T[] readNums(T)(){
  return readStr.split.to!(T[]);
}

string readStr(){
  return readln.chomp;
}

void main(){
  auto n = readNum!int;
  auto w = readNums!int;

  int ans = 10001;
  foreach(i; 1 .. n){
    ans = min(ans, abs(w[0 .. i].sum - w[i .. $].sum));
  }

  writeln(ans);
}
