import java.util.Scanner;

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

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