import java.awt.Point;
import java.util.Scanner;

public class Main {

    private static Point NA = new Point(0, 0);

    public static void main(String[] args) {
        int[] vals = input();
        int min = Integer.MAX_VALUE;
        for (int t = 1; t < vals.length; t++) {
            int diff = calc(t, vals);
            if (diff < min) {
                min = diff;
            }
        }
        System.out.println(min);
    }

    private static int calc(int t, int[] vals) {
        int sum1 = 0;
        int sum2 = 0;

        for (int i = 0; i < vals.length; i++) {
            if (i < t) {
                sum1 += vals[i];
            } else {
                sum2 += vals[i];
            }
        }

        return sum1 > sum2 ? sum1 - sum2 : sum2 - sum1;
    }

    private static int[] input() {
        try (Scanner scanner = new Scanner(System.in)) {
            int N = scanner.nextInt();
            int[] vals = new int[N];
            for (int i = 0; i < N; i++) {
                vals[i] = scanner.nextInt();
            }
            return vals;
        }
    }
} import java.awt.Point; Point java.awt import java.util.Scanner; Scanner java.util public class Main {

    private static Point NA = new Point(0, 0);

    public static void main(String[] args) {
        int[] vals = input();
        int min = Integer.MAX_VALUE;
        for (int t = 1; t < vals.length; t++) {
            int diff = calc(t, vals);
            if (diff < min) {
                min = diff;
            }
        }
        System.out.println(min);
    }

    private static int calc(int t, int[] vals) {
        int sum1 = 0;
        int sum2 = 0;

        for (int i = 0; i < vals.length; i++) {
            if (i < t) {
                sum1 += vals[i];
            } else {
                sum2 += vals[i];
            }
        }

        return sum1 > sum2 ? sum1 - sum2 : sum2 - sum1;
    }

    private static int[] input() {
        try (Scanner scanner = new Scanner(System.in)) {
            int N = scanner.nextInt();
            int[] vals = new int[N];
            for (int i = 0; i < N; i++) {
                vals[i] = scanner.nextInt();
            }
            return vals;
        }
    }
} Main private static Point NA = new Point(0, 0); NA new Point(0, 0) public static void main(String[] args) {
        int[] vals = input();
        int min = Integer.MAX_VALUE;
        for (int t = 1; t < vals.length; t++) {
            int diff = calc(t, vals);
            if (diff < min) {
                min = diff;
            }
        }
        System.out.println(min);
    } main {
        int[] vals = input();
        int min = Integer.MAX_VALUE;
        for (int t = 1; t < vals.length; t++) {
            int diff = calc(t, vals);
            if (diff < min) {
                min = diff;
            }
        }
        System.out.println(min);
    } int[] vals = input(); vals input() input int min = Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int t = 1; t < vals.length; t++) {
            int diff = calc(t, vals);
            if (diff < min) {
                min = diff;
            }
        } int t = 1; int t = 1; t 1 t < vals.length t vals.length vals vals.length t++ t++ t {
            int diff = calc(t, vals);
            if (diff < min) {
                min = diff;
            }
        } {
            int diff = calc(t, vals);
            if (diff < min) {
                min = diff;
            }
        } int diff = calc(t, vals); diff calc(t, vals) calc t vals if (diff < min) {
                min = diff;
            } diff < min diff min {
                min = diff;
            } min = diff min diff System.out.println(min) System.out.println System.out System System.out min String[] args args private static int calc(int t, int[] vals) {
        int sum1 = 0;
        int sum2 = 0;

        for (int i = 0; i < vals.length; i++) {
            if (i < t) {
                sum1 += vals[i];
            } else {
                sum2 += vals[i];
            }
        }

        return sum1 > sum2 ? sum1 - sum2 : sum2 - sum1;
    } calc {
        int sum1 = 0;
        int sum2 = 0;

        for (int i = 0; i < vals.length; i++) {
            if (i < t) {
                sum1 += vals[i];
            } else {
                sum2 += vals[i];
            }
        }

        return sum1 > sum2 ? sum1 - sum2 : sum2 - sum1;
    } int sum1 = 0; sum1 0 int sum2 = 0; sum2 0 for (int i = 0; i < vals.length; i++) {
            if (i < t) {
                sum1 += vals[i];
            } else {
                sum2 += vals[i];
            }
        } int i = 0; int i = 0; i 0 i < vals.length i vals.length vals vals.length i++ i++ i {
            if (i < t) {
                sum1 += vals[i];
            } else {
                sum2 += vals[i];
            }
        } {
            if (i < t) {
                sum1 += vals[i];
            } else {
                sum2 += vals[i];
            }
        } if (i < t) {
                sum1 += vals[i];
            } else {
                sum2 += vals[i];
            } i < t i t {
                sum1 += vals[i];
            } sum1 += vals[i] sum1 vals[i] vals i {
                sum2 += vals[i];
            } sum2 += vals[i] sum2 vals[i] vals i return sum1 > sum2 ? sum1 - sum2 : sum2 - sum1; sum1 > sum2 ? sum1 - sum2 : sum2 - sum1 sum1 > sum2 sum1 sum2 sum1 - sum2 sum1 sum2 sum2 - sum1 sum2 sum1 int t t int[] vals vals private static int[] input() {
        try (Scanner scanner = new Scanner(System.in)) {
            int N = scanner.nextInt();
            int[] vals = new int[N];
            for (int i = 0; i < N; i++) {
                vals[i] = scanner.nextInt();
            }
            return vals;
        }
    } input {
        try (Scanner scanner = new Scanner(System.in)) {
            int N = scanner.nextInt();
            int[] vals = new int[N];
            for (int i = 0; i < N; i++) {
                vals[i] = scanner.nextInt();
            }
            return vals;
        }
    } try (Scanner scanner = new Scanner(System.in)) {
            int N = scanner.nextInt();
            int[] vals = new int[N];
            for (int i = 0; i < N; i++) {
                vals[i] = scanner.nextInt();
            }
            return vals;
        } {
            int N = scanner.nextInt();
            int[] vals = new int[N];
            for (int i = 0; i < N; i++) {
                vals[i] = scanner.nextInt();
            }
            return vals;
        } Scanner scanner = new Scanner(System.in) Scanner scanner = new Scanner(System.in) new Scanner(System.in) int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner int[] vals = new int[N]; vals new int[N] N for (int i = 0; i < N; i++) {
                vals[i] = scanner.nextInt();
            } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
                vals[i] = scanner.nextInt();
            } {
                vals[i] = scanner.nextInt();
            } vals[i] = scanner.nextInt() vals[i] vals i scanner.nextInt() scanner.nextInt scanner return vals; vals public class Main {

    private static Point NA = new Point(0, 0);

    public static void main(String[] args) {
        int[] vals = input();
        int min = Integer.MAX_VALUE;
        for (int t = 1; t < vals.length; t++) {
            int diff = calc(t, vals);
            if (diff < min) {
                min = diff;
            }
        }
        System.out.println(min);
    }

    private static int calc(int t, int[] vals) {
        int sum1 = 0;
        int sum2 = 0;

        for (int i = 0; i < vals.length; i++) {
            if (i < t) {
                sum1 += vals[i];
            } else {
                sum2 += vals[i];
            }
        }

        return sum1 > sum2 ? sum1 - sum2 : sum2 - sum1;
    }

    private static int[] input() {
        try (Scanner scanner = new Scanner(System.in)) {
            int N = scanner.nextInt();
            int[] vals = new int[N];
            for (int i = 0; i < N; i++) {
                vals[i] = scanner.nextInt();
            }
            return vals;
        }
    }
} public class Main {

    private static Point NA = new Point(0, 0);

    public static void main(String[] args) {
        int[] vals = input();
        int min = Integer.MAX_VALUE;
        for (int t = 1; t < vals.length; t++) {
            int diff = calc(t, vals);
            if (diff < min) {
                min = diff;
            }
        }
        System.out.println(min);
    }

    private static int calc(int t, int[] vals) {
        int sum1 = 0;
        int sum2 = 0;

        for (int i = 0; i < vals.length; i++) {
            if (i < t) {
                sum1 += vals[i];
            } else {
                sum2 += vals[i];
            }
        }

        return sum1 > sum2 ? sum1 - sum2 : sum2 - sum1;
    }

    private static int[] input() {
        try (Scanner scanner = new Scanner(System.in)) {
            int N = scanner.nextInt();
            int[] vals = new int[N];
            for (int i = 0; i < N; i++) {
                vals[i] = scanner.nextInt();
            }
            return vals;
        }
    }
} Main
import java.awt.Point;
import java.util.Scanner;

public class Main {

    private static Point NA = new Point(0, 0);

    public static void main(String[] args) {
        int[] vals = input();
        int min = Integer.MAX_VALUE;
        for (int t = 1; t < vals.length; t++) {
            int diff = calc(t, vals);
            if (diff < min) {
                min = diff;
            }
        }
        System.out.println(min);
    }

    private static int calc(int t, int[] vals) {
        int sum1 = 0;
        int sum2 = 0;

        for (int i = 0; i < vals.length; i++) {
            if (i < t) {
                sum1 += vals[i];
            } else {
                sum2 += vals[i];
            }
        }

        return sum1 > sum2 ? sum1 - sum2 : sum2 - sum1;
    }

    private static int[] input() {
        try (Scanner scanner = new Scanner(System.in)) {
            int N = scanner.nextInt();
            int[] vals = new int[N];
            for (int i = 0; i < N; i++) {
                vals[i] = scanner.nextInt();
            }
            return vals;
        }
    }
}
