import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int[] b = new int[a];
        int sum = 0;
        int sum2 = 0;
        int answer = 1000000;
        for (int i = 0; i < a; i++) {
            b[i] = sc.nextInt();
            sum += b[i];
        }
        for (int i = 0; i < a; i++) {
            sum -= b[i];
            sum2 += b[i];
            answer = Math.min(answer, Math.abs(sum - sum2));
        }
        System.out.println(answer);
    }
} import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int[] b = new int[a];
        int sum = 0;
        int sum2 = 0;
        int answer = 1000000;
        for (int i = 0; i < a; i++) {
            b[i] = sc.nextInt();
            sum += b[i];
        }
        for (int i = 0; i < a; i++) {
            sum -= b[i];
            sum2 += b[i];
            answer = Math.min(answer, Math.abs(sum - sum2));
        }
        System.out.println(answer);
    }
} Main public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int[] b = new int[a];
        int sum = 0;
        int sum2 = 0;
        int answer = 1000000;
        for (int i = 0; i < a; i++) {
            b[i] = sc.nextInt();
            sum += b[i];
        }
        for (int i = 0; i < a; i++) {
            sum -= b[i];
            sum2 += b[i];
            answer = Math.min(answer, Math.abs(sum - sum2));
        }
        System.out.println(answer);
    } main {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int[] b = new int[a];
        int sum = 0;
        int sum2 = 0;
        int answer = 1000000;
        for (int i = 0; i < a; i++) {
            b[i] = sc.nextInt();
            sum += b[i];
        }
        for (int i = 0; i < a; i++) {
            sum -= b[i];
            sum2 += b[i];
            answer = Math.min(answer, Math.abs(sum - sum2));
        }
        System.out.println(answer);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int[] b = new int[a]; b new int[a] a int sum = 0; sum 0 int sum2 = 0; sum2 0 int answer = 1000000; answer 1000000 for (int i = 0; i < a; i++) {
            b[i] = sc.nextInt();
            sum += b[i];
        } int i = 0; int i = 0; i 0 i < a i a i++ i++ i {
            b[i] = sc.nextInt();
            sum += b[i];
        } {
            b[i] = sc.nextInt();
            sum += b[i];
        } b[i] = sc.nextInt() b[i] b i sc.nextInt() sc.nextInt sc sum += b[i] sum b[i] b i for (int i = 0; i < a; i++) {
            sum -= b[i];
            sum2 += b[i];
            answer = Math.min(answer, Math.abs(sum - sum2));
        } int i = 0; int i = 0; i 0 i < a i a i++ i++ i {
            sum -= b[i];
            sum2 += b[i];
            answer = Math.min(answer, Math.abs(sum - sum2));
        } {
            sum -= b[i];
            sum2 += b[i];
            answer = Math.min(answer, Math.abs(sum - sum2));
        } sum -= b[i] sum b[i] b i sum2 += b[i] sum2 b[i] b i answer = Math.min(answer, Math.abs(sum - sum2)) answer Math.min(answer, Math.abs(sum - sum2)) Math.min Math answer Math.abs(sum - sum2) Math.abs Math sum - sum2 sum sum2 System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main{
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int[] b = new int[a];
        int sum = 0;
        int sum2 = 0;
        int answer = 1000000;
        for (int i = 0; i < a; i++) {
            b[i] = sc.nextInt();
            sum += b[i];
        }
        for (int i = 0; i < a; i++) {
            sum -= b[i];
            sum2 += b[i];
            answer = Math.min(answer, Math.abs(sum - sum2));
        }
        System.out.println(answer);
    }
} public class Main{
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int[] b = new int[a];
        int sum = 0;
        int sum2 = 0;
        int answer = 1000000;
        for (int i = 0; i < a; i++) {
            b[i] = sc.nextInt();
            sum += b[i];
        }
        for (int i = 0; i < a; i++) {
            sum -= b[i];
            sum2 += b[i];
            answer = Math.min(answer, Math.abs(sum - sum2));
        }
        System.out.println(answer);
    }
} Main
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int[] b = new int[a];
        int sum = 0;
        int sum2 = 0;
        int answer = 1000000;
        for (int i = 0; i < a; i++) {
            b[i] = sc.nextInt();
            sum += b[i];
        }
        for (int i = 0; i < a; i++) {
            sum -= b[i];
            sum2 += b[i];
            answer = Math.min(answer, Math.abs(sum - sum2));
        }
        System.out.println(answer);
    }
}