import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        final int N = sc.nextInt();

        final int[] W = new int[N];
        for (int i = 0; i < N; i++) {
            W[i] = sc.nextInt();
        }

        int a = W[0];
        int b = 0;
        for (int i = 1; i < N; i++) {
            b += W[i];
        }

        int ans = Math.abs(a - b);

        for (int i = 1; i < N-1; i++) {
            a += W[i];
            b -= W[i];
            ans = Math.min(ans, Math.abs(a - b));
        }

        System.out.println(ans);
    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util import java.util.stream.IntStream; IntStream java.util.stream public class Main {

    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        final int N = sc.nextInt();

        final int[] W = new int[N];
        for (int i = 0; i < N; i++) {
            W[i] = sc.nextInt();
        }

        int a = W[0];
        int b = 0;
        for (int i = 1; i < N; i++) {
            b += W[i];
        }

        int ans = Math.abs(a - b);

        for (int i = 1; i < N-1; i++) {
            a += W[i];
            b -= W[i];
            ans = Math.min(ans, Math.abs(a - b));
        }

        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        final int N = sc.nextInt();

        final int[] W = new int[N];
        for (int i = 0; i < N; i++) {
            W[i] = sc.nextInt();
        }

        int a = W[0];
        int b = 0;
        for (int i = 1; i < N; i++) {
            b += W[i];
        }

        int ans = Math.abs(a - b);

        for (int i = 1; i < N-1; i++) {
            a += W[i];
            b -= W[i];
            ans = Math.min(ans, Math.abs(a - b));
        }

        System.out.println(ans);
    } main {
        final Scanner sc = new Scanner(System.in);

        final int N = sc.nextInt();

        final int[] W = new int[N];
        for (int i = 0; i < N; i++) {
            W[i] = sc.nextInt();
        }

        int a = W[0];
        int b = 0;
        for (int i = 1; i < N; i++) {
            b += W[i];
        }

        int ans = Math.abs(a - b);

        for (int i = 1; i < N-1; i++) {
            a += W[i];
            b -= W[i];
            ans = Math.min(ans, Math.abs(a - b));
        }

        System.out.println(ans);
    } final Scanner sc = new Scanner(System.in); sc new Scanner(System.in) final int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc final int[] W = new int[N]; W new int[N] N for (int i = 0; i < N; i++) {
            W[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            W[i] = sc.nextInt();
        } {
            W[i] = sc.nextInt();
        } W[i] = sc.nextInt() W[i] W i sc.nextInt() sc.nextInt sc int a = W[0]; a W[0] W 0 int b = 0; b 0 for (int i = 1; i < N; i++) {
            b += W[i];
        } int i = 1; int i = 1; i 1 i < N i N i++ i++ i {
            b += W[i];
        } {
            b += W[i];
        } b += W[i] b W[i] W i int ans = Math.abs(a - b); ans Math.abs(a - b) Math.abs Math a - b a b for (int i = 1; i < N-1; i++) {
            a += W[i];
            b -= W[i];
            ans = Math.min(ans, Math.abs(a - b));
        } int i = 1; int i = 1; i 1 i < N-1 i N-1 N 1 i++ i++ i {
            a += W[i];
            b -= W[i];
            ans = Math.min(ans, Math.abs(a - b));
        } {
            a += W[i];
            b -= W[i];
            ans = Math.min(ans, Math.abs(a - b));
        } a += W[i] a W[i] W i b -= W[i] b W[i] W i ans = Math.min(ans, Math.abs(a - b)) ans Math.min(ans, Math.abs(a - b)) Math.min Math ans Math.abs(a - b) Math.abs Math a - b a b 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) {
        final Scanner sc = new Scanner(System.in);

        final int N = sc.nextInt();

        final int[] W = new int[N];
        for (int i = 0; i < N; i++) {
            W[i] = sc.nextInt();
        }

        int a = W[0];
        int b = 0;
        for (int i = 1; i < N; i++) {
            b += W[i];
        }

        int ans = Math.abs(a - b);

        for (int i = 1; i < N-1; i++) {
            a += W[i];
            b -= W[i];
            ans = Math.min(ans, Math.abs(a - b));
        }

        System.out.println(ans);
    }
} public class Main {

    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        final int N = sc.nextInt();

        final int[] W = new int[N];
        for (int i = 0; i < N; i++) {
            W[i] = sc.nextInt();
        }

        int a = W[0];
        int b = 0;
        for (int i = 1; i < N; i++) {
            b += W[i];
        }

        int ans = Math.abs(a - b);

        for (int i = 1; i < N-1; i++) {
            a += W[i];
            b -= W[i];
            ans = Math.min(ans, Math.abs(a - b));
        }

        System.out.println(ans);
    }
} Main
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        final int N = sc.nextInt();

        final int[] W = new int[N];
        for (int i = 0; i < N; i++) {
            W[i] = sc.nextInt();
        }

        int a = W[0];
        int b = 0;
        for (int i = 1; i < N; i++) {
            b += W[i];
        }

        int ans = Math.abs(a - b);

        for (int i = 1; i < N-1; i++) {
            a += W[i];
            b -= W[i];
            ans = Math.min(ans, Math.abs(a - b));
        }

        System.out.println(ans);
    }
}
