import java.util.Scanner;

public class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {

        int n = sc.nextInt();

        int[] cum = new int[n+1];

        for (int i=0; i < n; i++) {
            cum[i+1] = cum[i] + sc.nextInt();
        }

        int min = Integer.MAX_VALUE;
        for (int i=0; i < n; i++) {
            min = Math.min(min, Math.abs((cum[n] - cum[i]) - (cum[i] - cum[0])));
        }

        System.out.println(min);
    }

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

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {

        int n = sc.nextInt();

        int[] cum = new int[n+1];

        for (int i=0; i < n; i++) {
            cum[i+1] = cum[i] + sc.nextInt();
        }

        int min = Integer.MAX_VALUE;
        for (int i=0; i < n; i++) {
            min = Math.min(min, Math.abs((cum[n] - cum[i]) - (cum[i] - cum[0])));
        }

        System.out.println(min);
    }

} Main private static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args) {

        int n = sc.nextInt();

        int[] cum = new int[n+1];

        for (int i=0; i < n; i++) {
            cum[i+1] = cum[i] + sc.nextInt();
        }

        int min = Integer.MAX_VALUE;
        for (int i=0; i < n; i++) {
            min = Math.min(min, Math.abs((cum[n] - cum[i]) - (cum[i] - cum[0])));
        }

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

        int n = sc.nextInt();

        int[] cum = new int[n+1];

        for (int i=0; i < n; i++) {
            cum[i+1] = cum[i] + sc.nextInt();
        }

        int min = Integer.MAX_VALUE;
        for (int i=0; i < n; i++) {
            min = Math.min(min, Math.abs((cum[n] - cum[i]) - (cum[i] - cum[0])));
        }

        System.out.println(min);
    } int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] cum = new int[n+1]; cum new int[n+1] n+1 n 1 for (int i=0; i < n; i++) {
            cum[i+1] = cum[i] + sc.nextInt();
        } int i=0; int i=0; i 0 i < n i n i++ i++ i {
            cum[i+1] = cum[i] + sc.nextInt();
        } {
            cum[i+1] = cum[i] + sc.nextInt();
        } cum[i+1] = cum[i] + sc.nextInt() cum[i+1] cum i+1 i 1 cum[i] + sc.nextInt() cum[i] cum i sc.nextInt() sc.nextInt sc int min = Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int i=0; i < n; i++) {
            min = Math.min(min, Math.abs((cum[n] - cum[i]) - (cum[i] - cum[0])));
        } int i=0; int i=0; i 0 i < n i n i++ i++ i {
            min = Math.min(min, Math.abs((cum[n] - cum[i]) - (cum[i] - cum[0])));
        } {
            min = Math.min(min, Math.abs((cum[n] - cum[i]) - (cum[i] - cum[0])));
        } min = Math.min(min, Math.abs((cum[n] - cum[i]) - (cum[i] - cum[0]))) min Math.min(min, Math.abs((cum[n] - cum[i]) - (cum[i] - cum[0]))) Math.min Math min Math.abs((cum[n] - cum[i]) - (cum[i] - cum[0])) Math.abs Math (cum[n] - cum[i]) - (cum[i] - cum[0]) (cum[n] - cum[i]) cum[n] cum n cum[i] cum i (cum[i] - cum[0]) cum[i] cum i cum[0] cum 0 System.out.println(min) System.out.println System.out System System.out min String[] args args public class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {

        int n = sc.nextInt();

        int[] cum = new int[n+1];

        for (int i=0; i < n; i++) {
            cum[i+1] = cum[i] + sc.nextInt();
        }

        int min = Integer.MAX_VALUE;
        for (int i=0; i < n; i++) {
            min = Math.min(min, Math.abs((cum[n] - cum[i]) - (cum[i] - cum[0])));
        }

        System.out.println(min);
    }

} public class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {

        int n = sc.nextInt();

        int[] cum = new int[n+1];

        for (int i=0; i < n; i++) {
            cum[i+1] = cum[i] + sc.nextInt();
        }

        int min = Integer.MAX_VALUE;
        for (int i=0; i < n; i++) {
            min = Math.min(min, Math.abs((cum[n] - cum[i]) - (cum[i] - cum[0])));
        }

        System.out.println(min);
    }

} Main
import java.util.Scanner;

public class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {

        int n = sc.nextInt();

        int[] cum = new int[n+1];

        for (int i=0; i < n; i++) {
            cum[i+1] = cum[i] + sc.nextInt();
        }

        int min = Integer.MAX_VALUE;
        for (int i=0; i < n; i++) {
            min = Math.min(min, Math.abs((cum[n] - cum[i]) - (cum[i] - cum[0])));
        }

        System.out.println(min);
    }

}
