import java.util.Scanner;

class Main {

    //https://atcoder.jp/contests/abc129/tasks/abc129_b
    public static void main( String[] args ) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int[] arr = new int[n];

        for (int i = 0; i < arr.length; i++)
            arr[i] = scanner.nextInt();

        if (arr.length == 2)
            System.out.println(Math.abs(arr[0] - arr[1]));

        int min = Integer.MAX_VALUE;
        for (int i = 1; i < arr.length; i++) {

            int sum1 = 0, sum2 = 0;
            for (int j = 0; j <= i; j++) {
                sum1 += arr[j];
            }

            for (int k = i + 1; k < arr.length; k++) {
                sum2 += arr[k];
            }

            min = Math.min(min, Math.abs(sum1 - sum2));
        }

        System.out.println(min);
    }
} import java.util.Scanner; Scanner java.util class Main {

    //https://atcoder.jp/contests/abc129/tasks/abc129_b
    public static void main( String[] args ) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int[] arr = new int[n];

        for (int i = 0; i < arr.length; i++)
            arr[i] = scanner.nextInt();

        if (arr.length == 2)
            System.out.println(Math.abs(arr[0] - arr[1]));

        int min = Integer.MAX_VALUE;
        for (int i = 1; i < arr.length; i++) {

            int sum1 = 0, sum2 = 0;
            for (int j = 0; j <= i; j++) {
                sum1 += arr[j];
            }

            for (int k = i + 1; k < arr.length; k++) {
                sum2 += arr[k];
            }

            min = Math.min(min, Math.abs(sum1 - sum2));
        }

        System.out.println(min);
    }
} Main //https://atcoder.jp/contests/abc129/tasks/abc129_b
    public static void main( String[] args ) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int[] arr = new int[n];

        for (int i = 0; i < arr.length; i++)
            arr[i] = scanner.nextInt();

        if (arr.length == 2)
            System.out.println(Math.abs(arr[0] - arr[1]));

        int min = Integer.MAX_VALUE;
        for (int i = 1; i < arr.length; i++) {

            int sum1 = 0, sum2 = 0;
            for (int j = 0; j <= i; j++) {
                sum1 += arr[j];
            }

            for (int k = i + 1; k < arr.length; k++) {
                sum2 += arr[k];
            }

            min = Math.min(min, Math.abs(sum1 - sum2));
        }

        System.out.println(min);
    } main {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int[] arr = new int[n];

        for (int i = 0; i < arr.length; i++)
            arr[i] = scanner.nextInt();

        if (arr.length == 2)
            System.out.println(Math.abs(arr[0] - arr[1]));

        int min = Integer.MAX_VALUE;
        for (int i = 1; i < arr.length; i++) {

            int sum1 = 0, sum2 = 0;
            for (int j = 0; j <= i; j++) {
                sum1 += arr[j];
            }

            for (int k = i + 1; k < arr.length; k++) {
                sum2 += arr[k];
            }

            min = Math.min(min, Math.abs(sum1 - sum2));
        }

        System.out.println(min);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner int[] arr = new int[n]; arr new int[n] n for (int i = 0; i < arr.length; i++)
            arr[i] = scanner.nextInt(); int i = 0; int i = 0; i 0 i < arr.length i arr.length arr arr.length i++ i++ i arr[i] = scanner.nextInt(); arr[i] = scanner.nextInt() arr[i] arr i scanner.nextInt() scanner.nextInt scanner if (arr.length == 2)
            System.out.println(Math.abs(arr[0] - arr[1])); arr.length == 2 arr.length arr arr.length 2 System.out.println(Math.abs(arr[0] - arr[1])) System.out.println System.out System System.out Math.abs(arr[0] - arr[1]) Math.abs Math arr[0] - arr[1] arr[0] arr 0 arr[1] arr 1 int min = Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int i = 1; i < arr.length; i++) {

            int sum1 = 0, sum2 = 0;
            for (int j = 0; j <= i; j++) {
                sum1 += arr[j];
            }

            for (int k = i + 1; k < arr.length; k++) {
                sum2 += arr[k];
            }

            min = Math.min(min, Math.abs(sum1 - sum2));
        } int i = 1; int i = 1; i 1 i < arr.length i arr.length arr arr.length i++ i++ i {

            int sum1 = 0, sum2 = 0;
            for (int j = 0; j <= i; j++) {
                sum1 += arr[j];
            }

            for (int k = i + 1; k < arr.length; k++) {
                sum2 += arr[k];
            }

            min = Math.min(min, Math.abs(sum1 - sum2));
        } {

            int sum1 = 0, sum2 = 0;
            for (int j = 0; j <= i; j++) {
                sum1 += arr[j];
            }

            for (int k = i + 1; k < arr.length; k++) {
                sum2 += arr[k];
            }

            min = Math.min(min, Math.abs(sum1 - sum2));
        } int sum1 = 0 sum1 0 sum2 = 0; sum2 0 for (int j = 0; j <= i; j++) {
                sum1 += arr[j];
            } int j = 0; int j = 0; j 0 j <= i j i j++ j++ j {
                sum1 += arr[j];
            } {
                sum1 += arr[j];
            } sum1 += arr[j] sum1 arr[j] arr j for (int k = i + 1; k < arr.length; k++) {
                sum2 += arr[k];
            } int k = i + 1; int k = i + 1; k i + 1 i 1 k < arr.length k arr.length arr arr.length k++ k++ k {
                sum2 += arr[k];
            } {
                sum2 += arr[k];
            } sum2 += arr[k] sum2 arr[k] arr k min = Math.min(min, Math.abs(sum1 - sum2)) min Math.min(min, Math.abs(sum1 - sum2)) Math.min Math min Math.abs(sum1 - sum2) Math.abs Math sum1 - sum2 sum1 sum2 System.out.println(min) System.out.println System.out System System.out min String[] args args
import java.util.Scanner;

class Main {

    //https://atcoder.jp/contests/abc129/tasks/abc129_b
    public static void main( String[] args ) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int[] arr = new int[n];

        for (int i = 0; i < arr.length; i++)
            arr[i] = scanner.nextInt();

        if (arr.length == 2)
            System.out.println(Math.abs(arr[0] - arr[1]));

        int min = Integer.MAX_VALUE;
        for (int i = 1; i < arr.length; i++) {

            int sum1 = 0, sum2 = 0;
            for (int j = 0; j <= i; j++) {
                sum1 += arr[j];
            }

            for (int k = i + 1; k < arr.length; k++) {
                sum2 += arr[k];
            }

            min = Math.min(min, Math.abs(sum1 - sum2));
        }

        System.out.println(min);
    }
}
