#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"n,*w=map(int,open(0).read().split());print(min(abs(sum(w[:i])-sum(w[i:]))for i in range(n)))\n"
"\"";
  system(s);
  return 0;
}            