import java.io.*;
import java.util.*;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        long[] W = new long[(int)(N)];
        for(int i = 0 ; i < N ; i++){
                W[i] = sc.nextLong();
        }

        final Solver solver = new Solver();
        solver.solve(N, W);
    }
}

class Solver {
    public void solve(long N, long[] W) {
        long min = Long.MAX_VALUE;

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

            long S2 = 0;
            for (int j = i + 1; j < N; j++) {
                S2 += W[j];
            }

            if (Math.abs(S1 - S2) < min) {
                min = Math.abs(S1 - S2);
            }
        }
        System.out.println(min);
    }
}
 import java.io.*; io.* java import java.util.*; util.* java public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        long[] W = new long[(int)(N)];
        for(int i = 0 ; i < N ; i++){
                W[i] = sc.nextLong();
        }

        final Solver solver = new Solver();
        solver.solve(N, W);
    }
} Main public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        long[] W = new long[(int)(N)];
        for(int i = 0 ; i < N ; i++){
                W[i] = sc.nextLong();
        }

        final Solver solver = new Solver();
        solver.solve(N, W);
    } main {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        long[] W = new long[(int)(N)];
        for(int i = 0 ; i < N ; i++){
                W[i] = sc.nextLong();
        }

        final Solver solver = new Solver();
        solver.solve(N, W);
    } final Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long N; N N = sc.nextLong() N sc.nextLong() sc.nextLong sc long[] W = new long[(int)(N)]; W new long[(int)(N)] (int)(N) for(int i = 0 ; i < N ; i++){
                W[i] = sc.nextLong();
        } int i = 0 ; int i = 0 ; i 0 i < N i N i++ i++ i {
                W[i] = sc.nextLong();
        } {
                W[i] = sc.nextLong();
        } W[i] = sc.nextLong() W[i] W i sc.nextLong() sc.nextLong sc final Solver solver = new Solver(); solver new Solver() solver.solve(N, W) solver.solve solver N W final String[] args args class Solver {
    public void solve(long N, long[] W) {
        long min = Long.MAX_VALUE;

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

            long S2 = 0;
            for (int j = i + 1; j < N; j++) {
                S2 += W[j];
            }

            if (Math.abs(S1 - S2) < min) {
                min = Math.abs(S1 - S2);
            }
        }
        System.out.println(min);
    }
} Solver public void solve(long N, long[] W) {
        long min = Long.MAX_VALUE;

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

            long S2 = 0;
            for (int j = i + 1; j < N; j++) {
                S2 += W[j];
            }

            if (Math.abs(S1 - S2) < min) {
                min = Math.abs(S1 - S2);
            }
        }
        System.out.println(min);
    } solve {
        long min = Long.MAX_VALUE;

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

            long S2 = 0;
            for (int j = i + 1; j < N; j++) {
                S2 += W[j];
            }

            if (Math.abs(S1 - S2) < min) {
                min = Math.abs(S1 - S2);
            }
        }
        System.out.println(min);
    } long min = Long.MAX_VALUE; min Long.MAX_VALUE Long Long.MAX_VALUE for (int i = 0; i < N; i++) {
            long S1 = 0;
            for (int j = 0; j <= i; j++) {
                S1 += W[j];
            }

            long S2 = 0;
            for (int j = i + 1; j < N; j++) {
                S2 += W[j];
            }

            if (Math.abs(S1 - S2) < min) {
                min = Math.abs(S1 - S2);
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            long S1 = 0;
            for (int j = 0; j <= i; j++) {
                S1 += W[j];
            }

            long S2 = 0;
            for (int j = i + 1; j < N; j++) {
                S2 += W[j];
            }

            if (Math.abs(S1 - S2) < min) {
                min = Math.abs(S1 - S2);
            }
        } {
            long S1 = 0;
            for (int j = 0; j <= i; j++) {
                S1 += W[j];
            }

            long S2 = 0;
            for (int j = i + 1; j < N; j++) {
                S2 += W[j];
            }

            if (Math.abs(S1 - S2) < min) {
                min = Math.abs(S1 - S2);
            }
        } long S1 = 0; S1 0 for (int j = 0; j <= i; j++) {
                S1 += W[j];
            } int j = 0; int j = 0; j 0 j <= i j i j++ j++ j {
                S1 += W[j];
            } {
                S1 += W[j];
            } S1 += W[j] S1 W[j] W j long S2 = 0; S2 0 for (int j = i + 1; j < N; j++) {
                S2 += W[j];
            } int j = i + 1; int j = i + 1; j i + 1 i 1 j < N j N j++ j++ j {
                S2 += W[j];
            } {
                S2 += W[j];
            } S2 += W[j] S2 W[j] W j if (Math.abs(S1 - S2) < min) {
                min = Math.abs(S1 - S2);
            } Math.abs(S1 - S2) < min Math.abs(S1 - S2) Math.abs Math S1 - S2 S1 S2 min {
                min = Math.abs(S1 - S2);
            } min = Math.abs(S1 - S2) min Math.abs(S1 - S2) Math.abs Math S1 - S2 S1 S2 System.out.println(min) System.out.println System.out System System.out min long N N long[] W W public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        long[] W = new long[(int)(N)];
        for(int i = 0 ; i < N ; i++){
                W[i] = sc.nextLong();
        }

        final Solver solver = new Solver();
        solver.solve(N, W);
    }
} public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        long[] W = new long[(int)(N)];
        for(int i = 0 ; i < N ; i++){
                W[i] = sc.nextLong();
        }

        final Solver solver = new Solver();
        solver.solve(N, W);
    }
} Main
import java.io.*;
import java.util.*;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        long[] W = new long[(int)(N)];
        for(int i = 0 ; i < N ; i++){
                W[i] = sc.nextLong();
        }

        final Solver solver = new Solver();
        solver.solve(N, W);
    }
}

class Solver {
    public void solve(long N, long[] W) {
        long min = Long.MAX_VALUE;

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

            long S2 = 0;
            for (int j = i + 1; j < N; j++) {
                S2 += W[j];
            }

            if (Math.abs(S1 - S2) < min) {
                min = Math.abs(S1 - S2);
            }
        }
        System.out.println(min);
    }
}

