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 bef = 0;
    int aft = 0;
    for(int i = 0;i<n;i++){
      w[i] = sc.nextInt();
      bef += w[i];
    }
    int dis = bef;
    for(int i = n-1;i>1;i--){
      bef -= w[i];
      aft += w[i];
      dis = Math.min(dis,Math.abs(bef - aft));
    }
    System.out.println(dis);
  }
} 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 bef = 0;
    int aft = 0;
    for(int i = 0;i<n;i++){
      w[i] = sc.nextInt();
      bef += w[i];
    }
    int dis = bef;
    for(int i = n-1;i>1;i--){
      bef -= w[i];
      aft += w[i];
      dis = Math.min(dis,Math.abs(bef - aft));
    }
    System.out.println(dis);
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] w = new int[n];
    int bef = 0;
    int aft = 0;
    for(int i = 0;i<n;i++){
      w[i] = sc.nextInt();
      bef += w[i];
    }
    int dis = bef;
    for(int i = n-1;i>1;i--){
      bef -= w[i];
      aft += w[i];
      dis = Math.min(dis,Math.abs(bef - aft));
    }
    System.out.println(dis);
  } main {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] w = new int[n];
    int bef = 0;
    int aft = 0;
    for(int i = 0;i<n;i++){
      w[i] = sc.nextInt();
      bef += w[i];
    }
    int dis = bef;
    for(int i = n-1;i>1;i--){
      bef -= w[i];
      aft += w[i];
      dis = Math.min(dis,Math.abs(bef - aft));
    }
    System.out.println(dis);
  } 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 bef = 0; bef 0 int aft = 0; aft 0 for(int i = 0;i<n;i++){
      w[i] = sc.nextInt();
      bef += w[i];
    } int i = 0; int i = 0; i 0 i<n i n i++ i++ i {
      w[i] = sc.nextInt();
      bef += w[i];
    } {
      w[i] = sc.nextInt();
      bef += w[i];
    } w[i] = sc.nextInt() w[i] w i sc.nextInt() sc.nextInt sc bef += w[i] bef w[i] w i int dis = bef; dis bef for(int i = n-1;i>1;i--){
      bef -= w[i];
      aft += w[i];
      dis = Math.min(dis,Math.abs(bef - aft));
    } int i = n-1; int i = n-1; i n-1 n 1 i>1 i 1 i-- i-- i {
      bef -= w[i];
      aft += w[i];
      dis = Math.min(dis,Math.abs(bef - aft));
    } {
      bef -= w[i];
      aft += w[i];
      dis = Math.min(dis,Math.abs(bef - aft));
    } bef -= w[i] bef w[i] w i aft += w[i] aft w[i] w i dis = Math.min(dis,Math.abs(bef - aft)) dis Math.min(dis,Math.abs(bef - aft)) Math.min Math dis Math.abs(bef - aft) Math.abs Math bef - aft bef aft System.out.println(dis) System.out.println System.out System System.out dis 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 bef = 0;
    int aft = 0;
    for(int i = 0;i<n;i++){
      w[i] = sc.nextInt();
      bef += w[i];
    }
    int dis = bef;
    for(int i = n-1;i>1;i--){
      bef -= w[i];
      aft += w[i];
      dis = Math.min(dis,Math.abs(bef - aft));
    }
    System.out.println(dis);
  }
} 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 bef = 0;
    int aft = 0;
    for(int i = 0;i<n;i++){
      w[i] = sc.nextInt();
      bef += w[i];
    }
    int dis = bef;
    for(int i = n-1;i>1;i--){
      bef -= w[i];
      aft += w[i];
      dis = Math.min(dis,Math.abs(bef - aft));
    }
    System.out.println(dis);
  }
} 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 bef = 0;
    int aft = 0;
    for(int i = 0;i<n;i++){
      w[i] = sc.nextInt();
      bef += w[i];
    }
    int dis = bef;
    for(int i = n-1;i>1;i--){
      bef -= w[i];
      aft += w[i];
      dis = Math.min(dis,Math.abs(bef - aft));
    }
    System.out.println(dis);
  }
}
