import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int po[]=new int[n];
        for(int i=0;i<n;i++){
            po[i]=(i==0)?sc.nextInt():sc.nextInt()+po[i-1];
        }
        int ans=Integer.MAX_VALUE;
        for(int i=0;i<n-1;i++){
            ans=Math.min(ans,Math.abs(po[i]-(po[n-1]-po[i])));
        }
        System.out.println(ans);
    }
} 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 po[]=new int[n];
        for(int i=0;i<n;i++){
            po[i]=(i==0)?sc.nextInt():sc.nextInt()+po[i-1];
        }
        int ans=Integer.MAX_VALUE;
        for(int i=0;i<n-1;i++){
            ans=Math.min(ans,Math.abs(po[i]-(po[n-1]-po[i])));
        }
        System.out.println(ans);
    }
} Main public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int po[]=new int[n];
        for(int i=0;i<n;i++){
            po[i]=(i==0)?sc.nextInt():sc.nextInt()+po[i-1];
        }
        int ans=Integer.MAX_VALUE;
        for(int i=0;i<n-1;i++){
            ans=Math.min(ans,Math.abs(po[i]-(po[n-1]-po[i])));
        }
        System.out.println(ans);
    } main {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int po[]=new int[n];
        for(int i=0;i<n;i++){
            po[i]=(i==0)?sc.nextInt():sc.nextInt()+po[i-1];
        }
        int ans=Integer.MAX_VALUE;
        for(int i=0;i<n-1;i++){
            ans=Math.min(ans,Math.abs(po[i]-(po[n-1]-po[i])));
        }
        System.out.println(ans);
    } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) int n=sc.nextInt(); n sc.nextInt() sc.nextInt sc int po[]=new int[n]; po new int[n] n for(int i=0;i<n;i++){
            po[i]=(i==0)?sc.nextInt():sc.nextInt()+po[i-1];
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            po[i]=(i==0)?sc.nextInt():sc.nextInt()+po[i-1];
        } {
            po[i]=(i==0)?sc.nextInt():sc.nextInt()+po[i-1];
        } po[i]=(i==0)?sc.nextInt():sc.nextInt()+po[i-1] po[i] po i (i==0)?sc.nextInt():sc.nextInt()+po[i-1] (i==0) i 0 sc.nextInt() sc.nextInt sc sc.nextInt()+po[i-1] sc.nextInt() sc.nextInt sc po[i-1] po i-1 i 1 int ans=Integer.MAX_VALUE; ans Integer.MAX_VALUE Integer Integer.MAX_VALUE for(int i=0;i<n-1;i++){
            ans=Math.min(ans,Math.abs(po[i]-(po[n-1]-po[i])));
        } int i=0; int i=0; i 0 i<n-1 i n-1 n 1 i++ i++ i {
            ans=Math.min(ans,Math.abs(po[i]-(po[n-1]-po[i])));
        } {
            ans=Math.min(ans,Math.abs(po[i]-(po[n-1]-po[i])));
        } ans=Math.min(ans,Math.abs(po[i]-(po[n-1]-po[i]))) ans Math.min(ans,Math.abs(po[i]-(po[n-1]-po[i]))) Math.min Math ans Math.abs(po[i]-(po[n-1]-po[i])) Math.abs Math po[i]-(po[n-1]-po[i]) po[i] po i (po[n-1]-po[i]) po[n-1] po n-1 n 1 po[i] po i System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int po[]=new int[n];
        for(int i=0;i<n;i++){
            po[i]=(i==0)?sc.nextInt():sc.nextInt()+po[i-1];
        }
        int ans=Integer.MAX_VALUE;
        for(int i=0;i<n-1;i++){
            ans=Math.min(ans,Math.abs(po[i]-(po[n-1]-po[i])));
        }
        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int po[]=new int[n];
        for(int i=0;i<n;i++){
            po[i]=(i==0)?sc.nextInt():sc.nextInt()+po[i-1];
        }
        int ans=Integer.MAX_VALUE;
        for(int i=0;i<n-1;i++){
            ans=Math.min(ans,Math.abs(po[i]-(po[n-1]-po[i])));
        }
        System.out.println(ans);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int po[]=new int[n];
        for(int i=0;i<n;i++){
            po[i]=(i==0)?sc.nextInt():sc.nextInt()+po[i-1];
        }
        int ans=Integer.MAX_VALUE;
        for(int i=0;i<n-1;i++){
            ans=Math.min(ans,Math.abs(po[i]-(po[n-1]-po[i])));
        }
        System.out.println(ans);
    }
}
