import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] w = new int[n];
      int s1 = 0;
      int s2 = 0;
      int count = 0;
      for(int i = 0;i < n;i++){
      	w[i] = sc.nextInt();
        s1 += w[i];
      }
      for(int i = 0;i < n && s1 > s2;i++){
      	s1 -= w[i];
        s2 += w[i];
        if(s1-s2 <= w[i+1]*2){
          count = i+1;
          break;
        }
      }
      System.out.println(Math.min(Math.abs(s1-s2),Math.abs(s1-s2-w[count]*2)));
    }
} import java.util.*; util.* java public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] w = new int[n];
      int s1 = 0;
      int s2 = 0;
      int count = 0;
      for(int i = 0;i < n;i++){
      	w[i] = sc.nextInt();
        s1 += w[i];
      }
      for(int i = 0;i < n && s1 > s2;i++){
      	s1 -= w[i];
        s2 += w[i];
        if(s1-s2 <= w[i+1]*2){
          count = i+1;
          break;
        }
      }
      System.out.println(Math.min(Math.abs(s1-s2),Math.abs(s1-s2-w[count]*2)));
    }
} Main public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] w = new int[n];
      int s1 = 0;
      int s2 = 0;
      int count = 0;
      for(int i = 0;i < n;i++){
      	w[i] = sc.nextInt();
        s1 += w[i];
      }
      for(int i = 0;i < n && s1 > s2;i++){
      	s1 -= w[i];
        s2 += w[i];
        if(s1-s2 <= w[i+1]*2){
          count = i+1;
          break;
        }
      }
      System.out.println(Math.min(Math.abs(s1-s2),Math.abs(s1-s2-w[count]*2)));
    } main {
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] w = new int[n];
      int s1 = 0;
      int s2 = 0;
      int count = 0;
      for(int i = 0;i < n;i++){
      	w[i] = sc.nextInt();
        s1 += w[i];
      }
      for(int i = 0;i < n && s1 > s2;i++){
      	s1 -= w[i];
        s2 += w[i];
        if(s1-s2 <= w[i+1]*2){
          count = i+1;
          break;
        }
      }
      System.out.println(Math.min(Math.abs(s1-s2),Math.abs(s1-s2-w[count]*2)));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] w = new int[n]; w new int[n] n int s1 = 0; s1 0 int s2 = 0; s2 0 int count = 0; count 0 for(int i = 0;i < n;i++){
      	w[i] = sc.nextInt();
        s1 += w[i];
      } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      	w[i] = sc.nextInt();
        s1 += w[i];
      } {
      	w[i] = sc.nextInt();
        s1 += w[i];
      } w[i] = sc.nextInt() w[i] w i sc.nextInt() sc.nextInt sc s1 += w[i] s1 w[i] w i for(int i = 0;i < n && s1 > s2;i++){
      	s1 -= w[i];
        s2 += w[i];
        if(s1-s2 <= w[i+1]*2){
          count = i+1;
          break;
        }
      } int i = 0; int i = 0; i 0 i < n && s1 > s2 i < n i n s1 > s2 s1 s2 i++ i++ i {
      	s1 -= w[i];
        s2 += w[i];
        if(s1-s2 <= w[i+1]*2){
          count = i+1;
          break;
        }
      } {
      	s1 -= w[i];
        s2 += w[i];
        if(s1-s2 <= w[i+1]*2){
          count = i+1;
          break;
        }
      } s1 -= w[i] s1 w[i] w i s2 += w[i] s2 w[i] w i if(s1-s2 <= w[i+1]*2){
          count = i+1;
          break;
        } s1-s2 <= w[i+1]*2 s1-s2 s1 s2 w[i+1]*2 w[i+1] w i+1 i 1 2 {
          count = i+1;
          break;
        } count = i+1 count i+1 i 1 break; System.out.println(Math.min(Math.abs(s1-s2),Math.abs(s1-s2-w[count]*2))) System.out.println System.out System System.out Math.min(Math.abs(s1-s2),Math.abs(s1-s2-w[count]*2)) Math.min Math Math.abs(s1-s2) Math.abs Math s1-s2 s1 s2 Math.abs(s1-s2-w[count]*2) Math.abs Math s1-s2-w[count]*2 s1-s2-w[count]*2 s1 s2 w[count]*2 w[count] w count 2 String[] args args public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] w = new int[n];
      int s1 = 0;
      int s2 = 0;
      int count = 0;
      for(int i = 0;i < n;i++){
      	w[i] = sc.nextInt();
        s1 += w[i];
      }
      for(int i = 0;i < n && s1 > s2;i++){
      	s1 -= w[i];
        s2 += w[i];
        if(s1-s2 <= w[i+1]*2){
          count = i+1;
          break;
        }
      }
      System.out.println(Math.min(Math.abs(s1-s2),Math.abs(s1-s2-w[count]*2)));
    }
} public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] w = new int[n];
      int s1 = 0;
      int s2 = 0;
      int count = 0;
      for(int i = 0;i < n;i++){
      	w[i] = sc.nextInt();
        s1 += w[i];
      }
      for(int i = 0;i < n && s1 > s2;i++){
      	s1 -= w[i];
        s2 += w[i];
        if(s1-s2 <= w[i+1]*2){
          count = i+1;
          break;
        }
      }
      System.out.println(Math.min(Math.abs(s1-s2),Math.abs(s1-s2-w[count]*2)));
    }
} Main
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] w = new int[n];
      int s1 = 0;
      int s2 = 0;
      int count = 0;
      for(int i = 0;i < n;i++){
      	w[i] = sc.nextInt();
        s1 += w[i];
      }
      for(int i = 0;i < n && s1 > s2;i++){
      	s1 -= w[i];
        s2 += w[i];
        if(s1-s2 <= w[i+1]*2){
          count = i+1;
          break;
        }
      }
      System.out.println(Math.min(Math.abs(s1-s2),Math.abs(s1-s2-w[count]*2)));
    }
}