import java.util.*;
 
class Main {
    public static void main(String[] args) {
      
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int asb = 0;
        int min = 1000;
        int sum2 = 0;
        int sum = 0;
        int nam[] = new int[N];

      for(int i = 0; i < N ;i++){
        nam[i] = sc.nextInt();
        sum += nam[i];
      }
      
       for(int i = 0; i < N-1;i++){
         sum -= nam[i];
         sum2 += nam[i];
         asb = Math.abs(sum-sum2);
         if(asb<min){min = asb;}
       }
      
      System.out.print(min);

    }
} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
      
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int asb = 0;
        int min = 1000;
        int sum2 = 0;
        int sum = 0;
        int nam[] = new int[N];

      for(int i = 0; i < N ;i++){
        nam[i] = sc.nextInt();
        sum += nam[i];
      }
      
       for(int i = 0; i < N-1;i++){
         sum -= nam[i];
         sum2 += nam[i];
         asb = Math.abs(sum-sum2);
         if(asb<min){min = asb;}
       }
      
      System.out.print(min);

    }
} Main public static void main(String[] args) {
      
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int asb = 0;
        int min = 1000;
        int sum2 = 0;
        int sum = 0;
        int nam[] = new int[N];

      for(int i = 0; i < N ;i++){
        nam[i] = sc.nextInt();
        sum += nam[i];
      }
      
       for(int i = 0; i < N-1;i++){
         sum -= nam[i];
         sum2 += nam[i];
         asb = Math.abs(sum-sum2);
         if(asb<min){min = asb;}
       }
      
      System.out.print(min);

    } main {
      
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int asb = 0;
        int min = 1000;
        int sum2 = 0;
        int sum = 0;
        int nam[] = new int[N];

      for(int i = 0; i < N ;i++){
        nam[i] = sc.nextInt();
        sum += nam[i];
      }
      
       for(int i = 0; i < N-1;i++){
         sum -= nam[i];
         sum2 += nam[i];
         asb = Math.abs(sum-sum2);
         if(asb<min){min = asb;}
       }
      
      System.out.print(min);

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int asb = 0; asb 0 int min = 1000; min 1000 int sum2 = 0; sum2 0 int sum = 0; sum 0 int nam[] = new int[N]; nam new int[N] N for(int i = 0; i < N ;i++){
        nam[i] = sc.nextInt();
        sum += nam[i];
      } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
        nam[i] = sc.nextInt();
        sum += nam[i];
      } {
        nam[i] = sc.nextInt();
        sum += nam[i];
      } nam[i] = sc.nextInt() nam[i] nam i sc.nextInt() sc.nextInt sc sum += nam[i] sum nam[i] nam i for(int i = 0; i < N-1;i++){
         sum -= nam[i];
         sum2 += nam[i];
         asb = Math.abs(sum-sum2);
         if(asb<min){min = asb;}
       } int i = 0; int i = 0; i 0 i < N-1 i N-1 N 1 i++ i++ i {
         sum -= nam[i];
         sum2 += nam[i];
         asb = Math.abs(sum-sum2);
         if(asb<min){min = asb;}
       } {
         sum -= nam[i];
         sum2 += nam[i];
         asb = Math.abs(sum-sum2);
         if(asb<min){min = asb;}
       } sum -= nam[i] sum nam[i] nam i sum2 += nam[i] sum2 nam[i] nam i asb = Math.abs(sum-sum2) asb Math.abs(sum-sum2) Math.abs Math sum-sum2 sum sum2 if(asb<min){min = asb;} asb<min asb min {min = asb;} min = asb min asb System.out.print(min) System.out.print System.out System System.out min String[] args args
import java.util.*;
 
class Main {
    public static void main(String[] args) {
      
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int asb = 0;
        int min = 1000;
        int sum2 = 0;
        int sum = 0;
        int nam[] = new int[N];

      for(int i = 0; i < N ;i++){
        nam[i] = sc.nextInt();
        sum += nam[i];
      }
      
       for(int i = 0; i < N-1;i++){
         sum -= nam[i];
         sum2 += nam[i];
         asb = Math.abs(sum-sum2);
         if(asb<min){min = asb;}
       }
      
      System.out.print(min);

    }
}