import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int[] s = new int[n];
        int total = 0;
        for (int i = 0; i < n; i++) {
            s[i] = sc.nextInt();
            total += s[i];
        }

        int min = Integer.MAX_VALUE;
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += s[i];
            if (min > Math.abs(sum - (total - sum))) {
                min = Math.abs(sum - (total - sum));
            }
        }

        System.out.print(min);
    }

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

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int[] s = new int[n];
        int total = 0;
        for (int i = 0; i < n; i++) {
            s[i] = sc.nextInt();
            total += s[i];
        }

        int min = Integer.MAX_VALUE;
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += s[i];
            if (min > Math.abs(sum - (total - sum))) {
                min = Math.abs(sum - (total - sum));
            }
        }

        System.out.print(min);
    }

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

        int[] s = new int[n];
        int total = 0;
        for (int i = 0; i < n; i++) {
            s[i] = sc.nextInt();
            total += s[i];
        }

        int min = Integer.MAX_VALUE;
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += s[i];
            if (min > Math.abs(sum - (total - sum))) {
                min = Math.abs(sum - (total - sum));
            }
        }

        System.out.print(min);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int[] s = new int[n];
        int total = 0;
        for (int i = 0; i < n; i++) {
            s[i] = sc.nextInt();
            total += s[i];
        }

        int min = Integer.MAX_VALUE;
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += s[i];
            if (min > Math.abs(sum - (total - sum))) {
                min = Math.abs(sum - (total - sum));
            }
        }

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

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int[] s = new int[n];
        int total = 0;
        for (int i = 0; i < n; i++) {
            s[i] = sc.nextInt();
            total += s[i];
        }

        int min = Integer.MAX_VALUE;
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += s[i];
            if (min > Math.abs(sum - (total - sum))) {
                min = Math.abs(sum - (total - sum));
            }
        }

        System.out.print(min);
    }

} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int[] s = new int[n];
        int total = 0;
        for (int i = 0; i < n; i++) {
            s[i] = sc.nextInt();
            total += s[i];
        }

        int min = Integer.MAX_VALUE;
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += s[i];
            if (min > Math.abs(sum - (total - sum))) {
                min = Math.abs(sum - (total - sum));
            }
        }

        System.out.print(min);
    }

} Main
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int[] s = new int[n];
        int total = 0;
        for (int i = 0; i < n; i++) {
            s[i] = sc.nextInt();
            total += s[i];
        }

        int min = Integer.MAX_VALUE;
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += s[i];
            if (min > Math.abs(sum - (total - sum))) {
                min = Math.abs(sum - (total - sum));
            }
        }

        System.out.print(min);
    }

}