import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] w = new int[n];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            sum += w[i];
        }
        int minDiff = Integer.MAX_VALUE;
        int group1 = 0;
        int group2 = sum;
        for (int i = 0; i < n - 1; i++) {
            group1 += w[i];
            group2 -= w[i];
            minDiff = Math.min(Math.abs(group1 - group2), minDiff);
        }
        System.out.println(minDiff);
    }

} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] w = new int[n];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            sum += w[i];
        }
        int minDiff = Integer.MAX_VALUE;
        int group1 = 0;
        int group2 = sum;
        for (int i = 0; i < n - 1; i++) {
            group1 += w[i];
            group2 -= w[i];
            minDiff = Math.min(Math.abs(group1 - group2), minDiff);
        }
        System.out.println(minDiff);
    }

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

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] w = new int[n];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            sum += w[i];
        }
        int minDiff = Integer.MAX_VALUE;
        int group1 = 0;
        int group2 = sum;
        for (int i = 0; i < n - 1; i++) {
            group1 += w[i];
            group2 -= w[i];
            minDiff = Math.min(Math.abs(group1 - group2), minDiff);
        }
        System.out.println(minDiff);
    }

} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] w = new int[n];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            sum += w[i];
        }
        int minDiff = Integer.MAX_VALUE;
        int group1 = 0;
        int group2 = sum;
        for (int i = 0; i < n - 1; i++) {
            group1 += w[i];
            group2 -= w[i];
            minDiff = Math.min(Math.abs(group1 - group2), minDiff);
        }
        System.out.println(minDiff);
    }

} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] w = new int[n];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            sum += w[i];
        }
        int minDiff = Integer.MAX_VALUE;
        int group1 = 0;
        int group2 = sum;
        for (int i = 0; i < n - 1; i++) {
            group1 += w[i];
            group2 -= w[i];
            minDiff = Math.min(Math.abs(group1 - group2), minDiff);
        }
        System.out.println(minDiff);
    }

}
