import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();

        int[] a = new int[n];
        int tot = 0;
        for(int i=0;i<n;i++){
            a[i] = in.nextInt();
            tot += a[i];
        }

        int best = Integer.MAX_VALUE, cur = 0;
        for(int i=0;i<n-1;i++){
            cur += a[i];
            best = Math.min(Math.abs(tot-2*cur),best);
        }

        System.out.println(best);
        in.close();
    }
} import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();

        int[] a = new int[n];
        int tot = 0;
        for(int i=0;i<n;i++){
            a[i] = in.nextInt();
            tot += a[i];
        }

        int best = Integer.MAX_VALUE, cur = 0;
        for(int i=0;i<n-1;i++){
            cur += a[i];
            best = Math.min(Math.abs(tot-2*cur),best);
        }

        System.out.println(best);
        in.close();
    }
} Main public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();

        int[] a = new int[n];
        int tot = 0;
        for(int i=0;i<n;i++){
            a[i] = in.nextInt();
            tot += a[i];
        }

        int best = Integer.MAX_VALUE, cur = 0;
        for(int i=0;i<n-1;i++){
            cur += a[i];
            best = Math.min(Math.abs(tot-2*cur),best);
        }

        System.out.println(best);
        in.close();
    } main {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();

        int[] a = new int[n];
        int tot = 0;
        for(int i=0;i<n;i++){
            a[i] = in.nextInt();
            tot += a[i];
        }

        int best = Integer.MAX_VALUE, cur = 0;
        for(int i=0;i<n-1;i++){
            cur += a[i];
            best = Math.min(Math.abs(tot-2*cur),best);
        }

        System.out.println(best);
        in.close();
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) int n = in.nextInt(); n in.nextInt() in.nextInt in int[] a = new int[n]; a new int[n] n int tot = 0; tot 0 for(int i=0;i<n;i++){
            a[i] = in.nextInt();
            tot += a[i];
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            a[i] = in.nextInt();
            tot += a[i];
        } {
            a[i] = in.nextInt();
            tot += a[i];
        } a[i] = in.nextInt() a[i] a i in.nextInt() in.nextInt in tot += a[i] tot a[i] a i int best = Integer.MAX_VALUE best Integer.MAX_VALUE Integer Integer.MAX_VALUE cur = 0; cur 0 for(int i=0;i<n-1;i++){
            cur += a[i];
            best = Math.min(Math.abs(tot-2*cur),best);
        } int i=0; int i=0; i 0 i<n-1 i n-1 n 1 i++ i++ i {
            cur += a[i];
            best = Math.min(Math.abs(tot-2*cur),best);
        } {
            cur += a[i];
            best = Math.min(Math.abs(tot-2*cur),best);
        } cur += a[i] cur a[i] a i best = Math.min(Math.abs(tot-2*cur),best) best Math.min(Math.abs(tot-2*cur),best) Math.min Math Math.abs(tot-2*cur) Math.abs Math tot-2*cur tot 2*cur 2 cur best System.out.println(best) System.out.println System.out System System.out best in.close() in.close in String[] args args public class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();

        int[] a = new int[n];
        int tot = 0;
        for(int i=0;i<n;i++){
            a[i] = in.nextInt();
            tot += a[i];
        }

        int best = Integer.MAX_VALUE, cur = 0;
        for(int i=0;i<n-1;i++){
            cur += a[i];
            best = Math.min(Math.abs(tot-2*cur),best);
        }

        System.out.println(best);
        in.close();
    }
} public class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();

        int[] a = new int[n];
        int tot = 0;
        for(int i=0;i<n;i++){
            a[i] = in.nextInt();
            tot += a[i];
        }

        int best = Integer.MAX_VALUE, cur = 0;
        for(int i=0;i<n-1;i++){
            cur += a[i];
            best = Math.min(Math.abs(tot-2*cur),best);
        }

        System.out.println(best);
        in.close();
    }
} Main
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();

        int[] a = new int[n];
        int tot = 0;
        for(int i=0;i<n;i++){
            a[i] = in.nextInt();
            tot += a[i];
        }

        int best = Integer.MAX_VALUE, cur = 0;
        for(int i=0;i<n-1;i++){
            cur += a[i];
            best = Math.min(Math.abs(tot-2*cur),best);
        }

        System.out.println(best);
        in.close();
    }
}