import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

struct Spl{auto r="".splitter;auto rd(){r=readln.splitter;}auto bd(T)(ref T t){t=r.front.to!T;r.popFront;}}
auto _s = Spl();
auto getV(T...)(ref T t){foreach(ref u;t)_s.bd(u);}
auto getA(T)(size_t n,ref T t){t=new T(n);foreach(ref u;t)_s.bd(u);}
auto readV(T...)(ref T t){_s.rd; getV(t);}
auto readA(T)(size_t n,ref T t){_s.rd;getA(n,t);}

void main()
{
  int n; readV(n);
  int[] w; readA(n, w);

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

  writeln(s);
}
