import java.util.Scanner;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] w = new int[N];
        w[0] = sc.nextInt();
        for (int i = 1; i < N; i++) {
            w[i] = w[i-1]+sc.nextInt();
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            int front = w[i];
            int back = w[N-1]-w[i];
            min = Math.min(min, Math.abs(back-front));
        }
        System.out.println(min);
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] w = new int[N];
        w[0] = sc.nextInt();
        for (int i = 1; i < N; i++) {
            w[i] = w[i-1]+sc.nextInt();
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            int front = w[i];
            int back = w[N-1]-w[i];
            min = Math.min(min, Math.abs(back-front));
        }
        System.out.println(min);
    }
} Main public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] w = new int[N];
        w[0] = sc.nextInt();
        for (int i = 1; i < N; i++) {
            w[i] = w[i-1]+sc.nextInt();
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            int front = w[i];
            int back = w[N-1]-w[i];
            min = Math.min(min, Math.abs(back-front));
        }
        System.out.println(min);
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] w = new int[N];
        w[0] = sc.nextInt();
        for (int i = 1; i < N; i++) {
            w[i] = w[i-1]+sc.nextInt();
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            int front = w[i];
            int back = w[N-1]-w[i];
            min = Math.min(min, Math.abs(back-front));
        }
        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[] w = new int[N]; w new int[N] N w[0] = sc.nextInt() w[0] w 0 sc.nextInt() sc.nextInt sc for (int i = 1; i < N; i++) {
            w[i] = w[i-1]+sc.nextInt();
        } int i = 1; int i = 1; i 1 i < N i N i++ i++ i {
            w[i] = w[i-1]+sc.nextInt();
        } {
            w[i] = w[i-1]+sc.nextInt();
        } w[i] = w[i-1]+sc.nextInt() w[i] w i w[i-1]+sc.nextInt() w[i-1] w i-1 i 1 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++) {
            int front = w[i];
            int back = w[N-1]-w[i];
            min = Math.min(min, Math.abs(back-front));
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            int front = w[i];
            int back = w[N-1]-w[i];
            min = Math.min(min, Math.abs(back-front));
        } {
            int front = w[i];
            int back = w[N-1]-w[i];
            min = Math.min(min, Math.abs(back-front));
        } int front = w[i]; front w[i] w i int back = w[N-1]-w[i]; back w[N-1]-w[i] w[N-1] w N-1 N 1 w[i] w i min = Math.min(min, Math.abs(back-front)) min Math.min(min, Math.abs(back-front)) Math.min Math min Math.abs(back-front) Math.abs Math back-front back front 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[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] w = new int[N];
        w[0] = sc.nextInt();
        for (int i = 1; i < N; i++) {
            w[i] = w[i-1]+sc.nextInt();
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            int front = w[i];
            int back = w[N-1]-w[i];
            min = Math.min(min, Math.abs(back-front));
        }
        System.out.println(min);
    }
} public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] w = new int[N];
        w[0] = sc.nextInt();
        for (int i = 1; i < N; i++) {
            w[i] = w[i-1]+sc.nextInt();
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            int front = w[i];
            int back = w[N-1]-w[i];
            min = Math.min(min, Math.abs(back-front));
        }
        System.out.println(min);
    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] w = new int[N];
        w[0] = sc.nextInt();
        for (int i = 1; i < N; i++) {
            w[i] = w[i-1]+sc.nextInt();
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            int front = w[i];
            int back = w[N-1]-w[i];
            min = Math.min(min, Math.abs(back-front));
        }
        System.out.println(min);
    }
}