// package app;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Scanner;
import java.util.StringJoiner;
import java.util.stream.Stream;

public class Main {

    public static void main(final String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);

        // long u = sc.nextLong();
        // long D = sc.nextLong();
        // long K = sc.nextLong();

        int N = sc.nextInt();
        // int X = sc.nextInt();

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

        int s1 = 0;
        int minimumDiff = Integer.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            s1 += W[i];
            s2 -= W[i];

            minimumDiff = Math.min(minimumDiff, Math.abs(s1 - s2));
        }

        System.out.println(minimumDiff);
    }
} import java.math.BigDecimal; BigDecimal java.math import java.util.Arrays; Arrays java.util import java.util.HashMap; HashMap java.util import java.util.Map; Map java.util import java.util.Objects; Objects java.util import java.util.Scanner; Scanner java.util import java.util.StringJoiner; StringJoiner java.util import java.util.stream.Stream; Stream java.util.stream public class Main {

    public static void main(final String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);

        // long u = sc.nextLong();
        // long D = sc.nextLong();
        // long K = sc.nextLong();

        int N = sc.nextInt();
        // int X = sc.nextInt();

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

        int s1 = 0;
        int minimumDiff = Integer.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            s1 += W[i];
            s2 -= W[i];

            minimumDiff = Math.min(minimumDiff, Math.abs(s1 - s2));
        }

        System.out.println(minimumDiff);
    }
} Main public static void main(final String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);

        // long u = sc.nextLong();
        // long D = sc.nextLong();
        // long K = sc.nextLong();

        int N = sc.nextInt();
        // int X = sc.nextInt();

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

        int s1 = 0;
        int minimumDiff = Integer.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            s1 += W[i];
            s2 -= W[i];

            minimumDiff = Math.min(minimumDiff, Math.abs(s1 - s2));
        }

        System.out.println(minimumDiff);
    } main {

        Scanner sc = new Scanner(System.in);

        // long u = sc.nextLong();
        // long D = sc.nextLong();
        // long K = sc.nextLong();

        int N = sc.nextInt();
        // int X = sc.nextInt();

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

        int s1 = 0;
        int minimumDiff = Integer.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            s1 += W[i];
            s2 -= W[i];

            minimumDiff = Math.min(minimumDiff, Math.abs(s1 - s2));
        }

        System.out.println(minimumDiff);
    } 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 s2 = 0; s2 0 for (int i = 0; i < N; i++) {
            W[i] = sc.nextInt();
            s2 += W[i];
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            W[i] = sc.nextInt();
            s2 += W[i];
        } {
            W[i] = sc.nextInt();
            s2 += W[i];
        } W[i] = sc.nextInt() W[i] W i sc.nextInt() sc.nextInt sc s2 += W[i] s2 W[i] W i int s1 = 0; s1 0 int minimumDiff = Integer.MAX_VALUE; minimumDiff Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int i = 0; i < N; i++) {
            s1 += W[i];
            s2 -= W[i];

            minimumDiff = Math.min(minimumDiff, Math.abs(s1 - s2));
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            s1 += W[i];
            s2 -= W[i];

            minimumDiff = Math.min(minimumDiff, Math.abs(s1 - s2));
        } {
            s1 += W[i];
            s2 -= W[i];

            minimumDiff = Math.min(minimumDiff, Math.abs(s1 - s2));
        } s1 += W[i] s1 W[i] W i s2 -= W[i] s2 W[i] W i minimumDiff = Math.min(minimumDiff, Math.abs(s1 - s2)) minimumDiff Math.min(minimumDiff, Math.abs(s1 - s2)) Math.min Math minimumDiff Math.abs(s1 - s2) Math.abs Math s1 - s2 s1 s2 System.out.println(minimumDiff) System.out.println System.out System System.out minimumDiff final String[] args args public class Main {

    public static void main(final String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);

        // long u = sc.nextLong();
        // long D = sc.nextLong();
        // long K = sc.nextLong();

        int N = sc.nextInt();
        // int X = sc.nextInt();

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

        int s1 = 0;
        int minimumDiff = Integer.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            s1 += W[i];
            s2 -= W[i];

            minimumDiff = Math.min(minimumDiff, Math.abs(s1 - s2));
        }

        System.out.println(minimumDiff);
    }
} public class Main {

    public static void main(final String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);

        // long u = sc.nextLong();
        // long D = sc.nextLong();
        // long K = sc.nextLong();

        int N = sc.nextInt();
        // int X = sc.nextInt();

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

        int s1 = 0;
        int minimumDiff = Integer.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            s1 += W[i];
            s2 -= W[i];

            minimumDiff = Math.min(minimumDiff, Math.abs(s1 - s2));
        }

        System.out.println(minimumDiff);
    }
} Main
// package app;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Scanner;
import java.util.StringJoiner;
import java.util.stream.Stream;

public class Main {

    public static void main(final String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);

        // long u = sc.nextLong();
        // long D = sc.nextLong();
        // long K = sc.nextLong();

        int N = sc.nextInt();
        // int X = sc.nextInt();

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

        int s1 = 0;
        int minimumDiff = Integer.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            s1 += W[i];
            s2 -= W[i];

            minimumDiff = Math.min(minimumDiff, Math.abs(s1 - s2));
        }

        System.out.println(minimumDiff);
    }
}