
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] sum = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            sum[i] = sum[i - 1] + sc.nextInt();
        }
        int min = sum[n];
        for (int i = 1; i <= n; i++) {
            min = Math.min(min, Math.abs(sum[n] - 2 * sum[i]));
        }
        System.out.println(min);
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] sum = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            sum[i] = sum[i - 1] + sc.nextInt();
        }
        int min = sum[n];
        for (int i = 1; i <= n; i++) {
            min = Math.min(min, Math.abs(sum[n] - 2 * sum[i]));
        }
        System.out.println(min);
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
} Main void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] sum = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            sum[i] = sum[i - 1] + sc.nextInt();
        }
        int min = sum[n];
        for (int i = 1; i <= n; i++) {
            min = Math.min(min, Math.abs(sum[n] - 2 * sum[i]));
        }
        System.out.println(min);
    } run {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] sum = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            sum[i] = sum[i - 1] + sc.nextInt();
        }
        int min = sum[n];
        for (int i = 1; i <= n; i++) {
            min = Math.min(min, Math.abs(sum[n] - 2 * sum[i]));
        }
        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[] sum = new int[n + 1]; sum new int[n + 1] n + 1 n 1 for (int i = 1; i <= n; i++) {
            sum[i] = sum[i - 1] + sc.nextInt();
        } int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
            sum[i] = sum[i - 1] + sc.nextInt();
        } {
            sum[i] = sum[i - 1] + sc.nextInt();
        } sum[i] = sum[i - 1] + sc.nextInt() sum[i] sum i sum[i - 1] + sc.nextInt() sum[i - 1] sum i - 1 i 1 sc.nextInt() sc.nextInt sc int min = sum[n]; min sum[n] sum n for (int i = 1; i <= n; i++) {
            min = Math.min(min, Math.abs(sum[n] - 2 * sum[i]));
        } int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
            min = Math.min(min, Math.abs(sum[n] - 2 * sum[i]));
        } {
            min = Math.min(min, Math.abs(sum[n] - 2 * sum[i]));
        } min = Math.min(min, Math.abs(sum[n] - 2 * sum[i])) min Math.min(min, Math.abs(sum[n] - 2 * sum[i])) Math.min Math min Math.abs(sum[n] - 2 * sum[i]) Math.abs Math sum[n] - 2 * sum[i] sum[n] sum n 2 * sum[i] 2 sum[i] sum i System.out.println(min) System.out.println System.out System System.out min void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    } debug {
        System.err.println(Arrays.deepToString(os));
    } System.err.println(Arrays.deepToString(os)) System.err.println System.err System System.err Arrays.deepToString(os) Arrays.deepToString Arrays os Object...os os public static void main(String[] args) {
        new Main().run();
    } main {
        new Main().run();
    } new Main().run() new Main().run new Main() String[] args args public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] sum = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            sum[i] = sum[i - 1] + sc.nextInt();
        }
        int min = sum[n];
        for (int i = 1; i <= n; i++) {
            min = Math.min(min, Math.abs(sum[n] - 2 * sum[i]));
        }
        System.out.println(min);
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
} public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] sum = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            sum[i] = sum[i - 1] + sc.nextInt();
        }
        int min = sum[n];
        for (int i = 1; i <= n; i++) {
            min = Math.min(min, Math.abs(sum[n] - 2 * sum[i]));
        }
        System.out.println(min);
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
} Main

import java.util.Arrays;
import java.util.Scanner;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] sum = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            sum[i] = sum[i - 1] + sc.nextInt();
        }
        int min = sum[n];
        for (int i = 1; i <= n; i++) {
            min = Math.min(min, Math.abs(sum[n] - 2 * sum[i]));
        }
        System.out.println(min);
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}
