import java.util.Scanner;

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 leftSum = W[0];
        int rightSum = 0;
        for (int i = 1; i < N; i++) {
            rightSum += W[i];
        }

        int ans = Math.abs(leftSum - rightSum);

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

        System.out.println(ans);
    }
} import java.util.Scanner; Scanner java.util 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 leftSum = W[0];
        int rightSum = 0;
        for (int i = 1; i < N; i++) {
            rightSum += W[i];
        }

        int ans = Math.abs(leftSum - rightSum);

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

        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 leftSum = W[0];
        int rightSum = 0;
        for (int i = 1; i < N; i++) {
            rightSum += W[i];
        }

        int ans = Math.abs(leftSum - rightSum);

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

        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 leftSum = W[0];
        int rightSum = 0;
        for (int i = 1; i < N; i++) {
            rightSum += W[i];
        }

        int ans = Math.abs(leftSum - rightSum);

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

        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 leftSum = W[0]; leftSum W[0] W 0 int rightSum = 0; rightSum 0 for (int i = 1; i < N; i++) {
            rightSum += W[i];
        } int i = 1; int i = 1; i 1 i < N i N i++ i++ i {
            rightSum += W[i];
        } {
            rightSum += W[i];
        } rightSum += W[i] rightSum W[i] W i int ans = Math.abs(leftSum - rightSum); ans Math.abs(leftSum - rightSum) Math.abs Math leftSum - rightSum leftSum rightSum for (int i = 1; i < N-1; i++) {
            leftSum += W[i];
            rightSum -= W[i];
            ans = Math.min(ans, Math.abs(leftSum - rightSum));
        } int i = 1; int i = 1; i 1 i < N-1 i N-1 N 1 i++ i++ i {
            leftSum += W[i];
            rightSum -= W[i];
            ans = Math.min(ans, Math.abs(leftSum - rightSum));
        } {
            leftSum += W[i];
            rightSum -= W[i];
            ans = Math.min(ans, Math.abs(leftSum - rightSum));
        } leftSum += W[i] leftSum W[i] W i rightSum -= W[i] rightSum W[i] W i ans = Math.min(ans, Math.abs(leftSum - rightSum)) ans Math.min(ans, Math.abs(leftSum - rightSum)) Math.min Math ans Math.abs(leftSum - rightSum) Math.abs Math leftSum - rightSum leftSum rightSum 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 leftSum = W[0];
        int rightSum = 0;
        for (int i = 1; i < N; i++) {
            rightSum += W[i];
        }

        int ans = Math.abs(leftSum - rightSum);

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

        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 leftSum = W[0];
        int rightSum = 0;
        for (int i = 1; i < N; i++) {
            rightSum += W[i];
        }

        int ans = Math.abs(leftSum - rightSum);

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

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

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 leftSum = W[0];
        int rightSum = 0;
        for (int i = 1; i < N; i++) {
            rightSum += W[i];
        }

        int ans = Math.abs(leftSum - rightSum);

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

        System.out.println(ans);
    }
}
