import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    private void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] W = new int[N];
        for (int i = 0; i < N; i++) {
            W[i] = sc.nextInt();
        }

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

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

        System.out.println(minDiff);
    }

    // Main
    public static void main(String[] args) {
        new Main().solve();
    }

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

    private void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] W = new int[N];
        for (int i = 0; i < N; i++) {
            W[i] = sc.nextInt();
        }

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

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

        System.out.println(minDiff);
    }

    // Main
    public static void main(String[] args) {
        new Main().solve();
    }

} Main private void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] W = new int[N];
        for (int i = 0; i < N; i++) {
            W[i] = sc.nextInt();
        }

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

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

        System.out.println(minDiff);
    } solve {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] W = new int[N];
        for (int i = 0; i < N; i++) {
            W[i] = sc.nextInt();
        }

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

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

        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 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 S1 = W[0]; S1 W[0] W 0 int S2 = 0; S2 0 for (int i = 1; i < N; i++) {
            S2 += W[i];
        } int i = 1; int i = 1; i 1 i < N i N i++ i++ i {
            S2 += W[i];
        } {
            S2 += W[i];
        } S2 += W[i] S2 W[i] W i int minDiff = Math.abs(S1 - S2); minDiff Math.abs(S1 - S2) Math.abs Math S1 - S2 S1 S2 for (int T = 1; T < N - 1; T++) {
            S1 += W[T];
            S2 -= W[T];
            minDiff = Math.min(minDiff, Math.abs(S1 - S2));
        } int T = 1; int T = 1; T 1 T < N - 1 T N - 1 N 1 T++ T++ T {
            S1 += W[T];
            S2 -= W[T];
            minDiff = Math.min(minDiff, Math.abs(S1 - S2));
        } {
            S1 += W[T];
            S2 -= W[T];
            minDiff = Math.min(minDiff, Math.abs(S1 - S2));
        } S1 += W[T] S1 W[T] W T S2 -= W[T] S2 W[T] W T 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 // Main
    public static void main(String[] args) {
        new Main().solve();
    } main {
        new Main().solve();
    } new Main().solve() new Main().solve new Main() String[] args args public class Main {

    private void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] W = new int[N];
        for (int i = 0; i < N; i++) {
            W[i] = sc.nextInt();
        }

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

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

        System.out.println(minDiff);
    }

    // Main
    public static void main(String[] args) {
        new Main().solve();
    }

} public class Main {

    private void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] W = new int[N];
        for (int i = 0; i < N; i++) {
            W[i] = sc.nextInt();
        }

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

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

        System.out.println(minDiff);
    }

    // Main
    public static void main(String[] args) {
        new Main().solve();
    }

} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    private void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] W = new int[N];
        for (int i = 0; i < N; i++) {
            W[i] = sc.nextInt();
        }

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

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

        System.out.println(minDiff);
    }

    // Main
    public static void main(String[] args) {
        new Main().solve();
    }

}
