import java.util.*;
 
class Main{
  static Scanner sc = new Scanner(System.in);
  public static void main(String args[]){
    int n=sc.nextInt();
    int a[] = new int[n+1];
    a[0]=0;
    for(int i=1;i<=n;i++){
      a[i]=a[i-1]+sc.nextInt();
    }
    int min=10000000;
    for(int t=1;t<n;t++){
      min=Math.min(Math.abs((a[t]-a[0])-(a[n]-a[t])),min);
    }
    System.out.println(min);
  }
} import java.util.*; util.* java class Main{
  static Scanner sc = new Scanner(System.in);
  public static void main(String args[]){
    int n=sc.nextInt();
    int a[] = new int[n+1];
    a[0]=0;
    for(int i=1;i<=n;i++){
      a[i]=a[i-1]+sc.nextInt();
    }
    int min=10000000;
    for(int t=1;t<n;t++){
      min=Math.min(Math.abs((a[t]-a[0])-(a[n]-a[t])),min);
    }
    System.out.println(min);
  }
} Main static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public static void main(String args[]){
    int n=sc.nextInt();
    int a[] = new int[n+1];
    a[0]=0;
    for(int i=1;i<=n;i++){
      a[i]=a[i-1]+sc.nextInt();
    }
    int min=10000000;
    for(int t=1;t<n;t++){
      min=Math.min(Math.abs((a[t]-a[0])-(a[n]-a[t])),min);
    }
    System.out.println(min);
  } main {
    int n=sc.nextInt();
    int a[] = new int[n+1];
    a[0]=0;
    for(int i=1;i<=n;i++){
      a[i]=a[i-1]+sc.nextInt();
    }
    int min=10000000;
    for(int t=1;t<n;t++){
      min=Math.min(Math.abs((a[t]-a[0])-(a[n]-a[t])),min);
    }
    System.out.println(min);
  } int n=sc.nextInt(); n sc.nextInt() sc.nextInt sc int a[] = new int[n+1]; a new int[n+1] n+1 n 1 a[0]=0 a[0] a 0 0 for(int i=1;i<=n;i++){
      a[i]=a[i-1]+sc.nextInt();
    } int i=1; int i=1; i 1 i<=n i n i++ i++ i {
      a[i]=a[i-1]+sc.nextInt();
    } {
      a[i]=a[i-1]+sc.nextInt();
    } a[i]=a[i-1]+sc.nextInt() a[i] a i a[i-1]+sc.nextInt() a[i-1] a i-1 i 1 sc.nextInt() sc.nextInt sc int min=10000000; min 10000000 for(int t=1;t<n;t++){
      min=Math.min(Math.abs((a[t]-a[0])-(a[n]-a[t])),min);
    } int t=1; int t=1; t 1 t<n t n t++ t++ t {
      min=Math.min(Math.abs((a[t]-a[0])-(a[n]-a[t])),min);
    } {
      min=Math.min(Math.abs((a[t]-a[0])-(a[n]-a[t])),min);
    } min=Math.min(Math.abs((a[t]-a[0])-(a[n]-a[t])),min) min Math.min(Math.abs((a[t]-a[0])-(a[n]-a[t])),min) Math.min Math Math.abs((a[t]-a[0])-(a[n]-a[t])) Math.abs Math (a[t]-a[0])-(a[n]-a[t]) (a[t]-a[0]) a[t] a t a[0] a 0 (a[n]-a[t]) a[n] a n a[t] a t min System.out.println(min) System.out.println System.out System System.out min String args[] args
import java.util.*;
 
class Main{
  static Scanner sc = new Scanner(System.in);
  public static void main(String args[]){
    int n=sc.nextInt();
    int a[] = new int[n+1];
    a[0]=0;
    for(int i=1;i<=n;i++){
      a[i]=a[i-1]+sc.nextInt();
    }
    int min=10000000;
    for(int t=1;t<n;t++){
      min=Math.min(Math.abs((a[t]-a[0])-(a[n]-a[t])),min);
    }
    System.out.println(min);
  }
}