import java.util.*;

public class Main {

    public static void main(String[] args) {
	    // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] list = new int[n];

        int sum = 0;
        for (int i = 0; i < n; i++) {
            int value = sc.nextInt();
            sum += value;
            list[i] = sum;
        }
        int min = Integer.MAX_VALUE;
        for (int value: list
             ) {
            int target = Math.abs(value - (sum - value));
            if (target < min) {
                min = target;
            }
        }
        System.out.println(min);
    }
} import java.util.*; util.* java public class Main {

    public static void main(String[] args) {
	    // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] list = new int[n];

        int sum = 0;
        for (int i = 0; i < n; i++) {
            int value = sc.nextInt();
            sum += value;
            list[i] = sum;
        }
        int min = Integer.MAX_VALUE;
        for (int value: list
             ) {
            int target = Math.abs(value - (sum - value));
            if (target < min) {
                min = target;
            }
        }
        System.out.println(min);
    }
} Main public static void main(String[] args) {
	    // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] list = new int[n];

        int sum = 0;
        for (int i = 0; i < n; i++) {
            int value = sc.nextInt();
            sum += value;
            list[i] = sum;
        }
        int min = Integer.MAX_VALUE;
        for (int value: list
             ) {
            int target = Math.abs(value - (sum - value));
            if (target < min) {
                min = target;
            }
        }
        System.out.println(min);
    } main {
	    // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] list = new int[n];

        int sum = 0;
        for (int i = 0; i < n; i++) {
            int value = sc.nextInt();
            sum += value;
            list[i] = sum;
        }
        int min = Integer.MAX_VALUE;
        for (int value: list
             ) {
            int target = Math.abs(value - (sum - value));
            if (target < min) {
                min = target;
            }
        }
        System.out.println(min);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] list = new int[n]; list new int[n] n int sum = 0; sum 0 for (int i = 0; i < n; i++) {
            int value = sc.nextInt();
            sum += value;
            list[i] = sum;
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            int value = sc.nextInt();
            sum += value;
            list[i] = sum;
        } {
            int value = sc.nextInt();
            sum += value;
            list[i] = sum;
        } int value = sc.nextInt(); value sc.nextInt() sc.nextInt sc sum += value sum value list[i] = sum list[i] list i sum int min = Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int value: list
             ) {
            int target = Math.abs(value - (sum - value));
            if (target < min) {
                min = target;
            }
        } int value list {
            int target = Math.abs(value - (sum - value));
            if (target < min) {
                min = target;
            }
        } {
            int target = Math.abs(value - (sum - value));
            if (target < min) {
                min = target;
            }
        } int target = Math.abs(value - (sum - value)); target Math.abs(value - (sum - value)) Math.abs Math value - (sum - value) value (sum - value) sum value if (target < min) {
                min = target;
            } target < min target min {
                min = target;
            } min = target min target System.out.println(min) System.out.println System.out System System.out min String[] args args public class Main {

    public static void main(String[] args) {
	    // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] list = new int[n];

        int sum = 0;
        for (int i = 0; i < n; i++) {
            int value = sc.nextInt();
            sum += value;
            list[i] = sum;
        }
        int min = Integer.MAX_VALUE;
        for (int value: list
             ) {
            int target = Math.abs(value - (sum - value));
            if (target < min) {
                min = target;
            }
        }
        System.out.println(min);
    }
} public class Main {

    public static void main(String[] args) {
	    // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] list = new int[n];

        int sum = 0;
        for (int i = 0; i < n; i++) {
            int value = sc.nextInt();
            sum += value;
            list[i] = sum;
        }
        int min = Integer.MAX_VALUE;
        for (int value: list
             ) {
            int target = Math.abs(value - (sum - value));
            if (target < min) {
                min = target;
            }
        }
        System.out.println(min);
    }
} Main
import java.util.*;

public class Main {

    public static void main(String[] args) {
	    // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] list = new int[n];

        int sum = 0;
        for (int i = 0; i < n; i++) {
            int value = sc.nextInt();
            sum += value;
            list[i] = sum;
        }
        int min = Integer.MAX_VALUE;
        for (int value: list
             ) {
            int target = Math.abs(value - (sum - value));
            if (target < min) {
                min = target;
            }
        }
        System.out.println(min);
    }
}