import java.util.Scanner;

public class Main {
    static int N;
    static int[] w;

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

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

        scanner.close();

        int ans = Integer.MAX_VALUE;
        int s1 = 0;
        for(int i = 0; i < N - 1; i++) {
            int s2 = 0;
            for(int j = N - 1; i + 1 <= j; j--) {
                s2 += w[j];
            }
            s1 += w[i];
            ans = Math.min(ans, Math.abs(s1 - s2));
        }

        System.out.println(ans);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    static int N;
    static int[] w;

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

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

        scanner.close();

        int ans = Integer.MAX_VALUE;
        int s1 = 0;
        for(int i = 0; i < N - 1; i++) {
            int s2 = 0;
            for(int j = N - 1; i + 1 <= j; j--) {
                s2 += w[j];
            }
            s1 += w[i];
            ans = Math.min(ans, Math.abs(s1 - s2));
        }

        System.out.println(ans);
    }
} Main static int N; N static int[] w; w public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();

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

        scanner.close();

        int ans = Integer.MAX_VALUE;
        int s1 = 0;
        for(int i = 0; i < N - 1; i++) {
            int s2 = 0;
            for(int j = N - 1; i + 1 <= j; j--) {
                s2 += w[j];
            }
            s1 += w[i];
            ans = Math.min(ans, Math.abs(s1 - s2));
        }

        System.out.println(ans);
    } main {
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();

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

        scanner.close();

        int ans = Integer.MAX_VALUE;
        int s1 = 0;
        for(int i = 0; i < N - 1; i++) {
            int s2 = 0;
            for(int j = N - 1; i + 1 <= j; j--) {
                s2 += w[j];
            }
            s1 += w[i];
            ans = Math.min(ans, Math.abs(s1 - s2));
        }

        System.out.println(ans);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) N = scanner.nextInt() N scanner.nextInt() scanner.nextInt scanner 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 scanner.close() scanner.close scanner int ans = Integer.MAX_VALUE; ans Integer.MAX_VALUE Integer Integer.MAX_VALUE int s1 = 0; s1 0 for(int i = 0; i < N - 1; i++) {
            int s2 = 0;
            for(int j = N - 1; i + 1 <= j; j--) {
                s2 += w[j];
            }
            s1 += w[i];
            ans = Math.min(ans, Math.abs(s1 - s2));
        } int i = 0; int i = 0; i 0 i < N - 1 i N - 1 N 1 i++ i++ i {
            int s2 = 0;
            for(int j = N - 1; i + 1 <= j; j--) {
                s2 += w[j];
            }
            s1 += w[i];
            ans = Math.min(ans, Math.abs(s1 - s2));
        } {
            int s2 = 0;
            for(int j = N - 1; i + 1 <= j; j--) {
                s2 += w[j];
            }
            s1 += w[i];
            ans = Math.min(ans, Math.abs(s1 - s2));
        } int s2 = 0; s2 0 for(int j = N - 1; i + 1 <= j; j--) {
                s2 += w[j];
            } int j = N - 1; int j = N - 1; j N - 1 N 1 i + 1 <= j i + 1 i 1 j j-- j-- j {
                s2 += w[j];
            } {
                s2 += w[j];
            } s2 += w[j] s2 w[j] w j s1 += w[i] s1 w[i] w i ans = Math.min(ans, Math.abs(s1 - s2)) ans Math.min(ans, Math.abs(s1 - s2)) Math.min Math ans Math.abs(s1 - s2) Math.abs Math s1 - s2 s1 s2 System.out.println(ans) System.out.println System.out System System.out ans String args[] args public class Main {
    static int N;
    static int[] w;

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

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

        scanner.close();

        int ans = Integer.MAX_VALUE;
        int s1 = 0;
        for(int i = 0; i < N - 1; i++) {
            int s2 = 0;
            for(int j = N - 1; i + 1 <= j; j--) {
                s2 += w[j];
            }
            s1 += w[i];
            ans = Math.min(ans, Math.abs(s1 - s2));
        }

        System.out.println(ans);
    }
} public class Main {
    static int N;
    static int[] w;

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

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

        scanner.close();

        int ans = Integer.MAX_VALUE;
        int s1 = 0;
        for(int i = 0; i < N - 1; i++) {
            int s2 = 0;
            for(int j = N - 1; i + 1 <= j; j--) {
                s2 += w[j];
            }
            s1 += w[i];
            ans = Math.min(ans, Math.abs(s1 - s2));
        }

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

public class Main {
    static int N;
    static int[] w;

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

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

        scanner.close();

        int ans = Integer.MAX_VALUE;
        int s1 = 0;
        for(int i = 0; i < N - 1; i++) {
            int s2 = 0;
            for(int j = N - 1; i + 1 <= j; j--) {
                s2 += w[j];
            }
            s1 += w[i];
            ans = Math.min(ans, Math.abs(s1 - s2));
        }

        System.out.println(ans);
    }
}