
import java.util.Scanner;

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

        int N = scanner.nextInt();
        int[] W = new int[N];

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

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

        int S1 = 0;
        int minDiff = Integer.MAX_VALUE;
        for (int i = 0 ; i < N - 1 ; i++) {
            S1 += W[i];
            int S2 = total - S1;
            minDiff = Math.min(minDiff, Math.abs(S1 - S2));
        }

        System.out.println(minDiff);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int[] W = new int[N];

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

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

        int S1 = 0;
        int minDiff = Integer.MAX_VALUE;
        for (int i = 0 ; i < N - 1 ; i++) {
            S1 += W[i];
            int S2 = total - S1;
            minDiff = Math.min(minDiff, Math.abs(S1 - S2));
        }

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

        int N = scanner.nextInt();
        int[] W = new int[N];

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

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

        int S1 = 0;
        int minDiff = Integer.MAX_VALUE;
        for (int i = 0 ; i < N - 1 ; i++) {
            S1 += W[i];
            int S2 = total - S1;
            minDiff = Math.min(minDiff, Math.abs(S1 - S2));
        }

        System.out.println(minDiff);
    } main {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int[] W = new int[N];

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

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

        int S1 = 0;
        int minDiff = Integer.MAX_VALUE;
        for (int i = 0 ; i < N - 1 ; i++) {
            S1 += W[i];
            int S2 = total - S1;
            minDiff = Math.min(minDiff, Math.abs(S1 - S2));
        }

        System.out.println(minDiff);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner int[] W = new int[N]; W new int[N] N for (int i = 0 ; i < N ; i++) {
            W[i] = scanner.nextInt();
        } int i = 0 ; int i = 0 ; i 0 i < N i N i++ i++ i {
            W[i] = scanner.nextInt();
        } {
            W[i] = scanner.nextInt();
        } W[i] = scanner.nextInt() W[i] W i scanner.nextInt() scanner.nextInt scanner int total = 0; total 0 for (int i = 0 ; i < N ; i++) {
            total += W[i];
        } int i = 0 ; int i = 0 ; i 0 i < N i N i++ i++ i {
            total += W[i];
        } {
            total += W[i];
        } total += W[i] total W[i] W i int S1 = 0; S1 0 int minDiff = Integer.MAX_VALUE; minDiff Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int i = 0 ; i < N - 1 ; i++) {
            S1 += W[i];
            int S2 = total - S1;
            minDiff = Math.min(minDiff, Math.abs(S1 - S2));
        } int i = 0 ; int i = 0 ; i 0 i < N - 1 i N - 1 N 1 i++ i++ i {
            S1 += W[i];
            int S2 = total - S1;
            minDiff = Math.min(minDiff, Math.abs(S1 - S2));
        } {
            S1 += W[i];
            int S2 = total - S1;
            minDiff = Math.min(minDiff, Math.abs(S1 - S2));
        } S1 += W[i] S1 W[i] W i int S2 = total - S1; S2 total - S1 total S1 minDiff = Math.min(minDiff, Math.abs(S1 - S2)) minDiff Math.min(minDiff, Math.abs(S1 - S2)) Math.min Math minDiff Math.abs(S1 - S2) Math.abs Math S1 - S2 S1 S2 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 scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int[] W = new int[N];

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

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

        int S1 = 0;
        int minDiff = Integer.MAX_VALUE;
        for (int i = 0 ; i < N - 1 ; i++) {
            S1 += W[i];
            int S2 = total - S1;
            minDiff = Math.min(minDiff, Math.abs(S1 - S2));
        }

        System.out.println(minDiff);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int[] W = new int[N];

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

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

        int S1 = 0;
        int minDiff = Integer.MAX_VALUE;
        for (int i = 0 ; i < N - 1 ; i++) {
            S1 += W[i];
            int S2 = total - S1;
            minDiff = Math.min(minDiff, Math.abs(S1 - S2));
        }

        System.out.println(minDiff);
    }
} Main

import java.util.Scanner;

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

        int N = scanner.nextInt();
        int[] W = new int[N];

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

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

        int S1 = 0;
        int minDiff = Integer.MAX_VALUE;
        for (int i = 0 ; i < N - 1 ; i++) {
            S1 += W[i];
            int S2 = total - S1;
            minDiff = Math.min(minDiff, Math.abs(S1 - S2));
        }

        System.out.println(minDiff);
    }
}
