import java.util.Scanner;

class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int N;
			int re = 9999999;
			int S1 = 0;
			int S2 = 0;
			int[] W;

			N = sc.nextInt();
			W = new int[N];
			for(int i = 0;i < N; i++) {
					W[i] = sc.nextInt();
					S2 += W[i];
			}

			for (int i = 0; i < N; i++ ){
					S1 += W[i];
					S2 -= W[i];
					if(S1 > S2){
							if(re > S1 - S2){
									re = S1 - S2;
							}
					}else {
							if(re > S2 - S1){
									re = S2 - S1;
							}
					}
			}
			System.out.println(re);
    }
} import java.util.Scanner; Scanner java.util class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int N;
			int re = 9999999;
			int S1 = 0;
			int S2 = 0;
			int[] W;

			N = sc.nextInt();
			W = new int[N];
			for(int i = 0;i < N; i++) {
					W[i] = sc.nextInt();
					S2 += W[i];
			}

			for (int i = 0; i < N; i++ ){
					S1 += W[i];
					S2 -= W[i];
					if(S1 > S2){
							if(re > S1 - S2){
									re = S1 - S2;
							}
					}else {
							if(re > S2 - S1){
									re = S2 - S1;
							}
					}
			}
			System.out.println(re);
    }
} Main public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int N;
			int re = 9999999;
			int S1 = 0;
			int S2 = 0;
			int[] W;

			N = sc.nextInt();
			W = new int[N];
			for(int i = 0;i < N; i++) {
					W[i] = sc.nextInt();
					S2 += W[i];
			}

			for (int i = 0; i < N; i++ ){
					S1 += W[i];
					S2 -= W[i];
					if(S1 > S2){
							if(re > S1 - S2){
									re = S1 - S2;
							}
					}else {
							if(re > S2 - S1){
									re = S2 - S1;
							}
					}
			}
			System.out.println(re);
    } main {
    	Scanner sc = new Scanner(System.in);
      int N;
			int re = 9999999;
			int S1 = 0;
			int S2 = 0;
			int[] W;

			N = sc.nextInt();
			W = new int[N];
			for(int i = 0;i < N; i++) {
					W[i] = sc.nextInt();
					S2 += W[i];
			}

			for (int i = 0; i < N; i++ ){
					S1 += W[i];
					S2 -= W[i];
					if(S1 > S2){
							if(re > S1 - S2){
									re = S1 - S2;
							}
					}else {
							if(re > S2 - S1){
									re = S2 - S1;
							}
					}
			}
			System.out.println(re);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N; N int re = 9999999; re 9999999 int S1 = 0; S1 0 int S2 = 0; S2 0 int[] W; W N = sc.nextInt() N sc.nextInt() sc.nextInt sc W = new int[N] W new int[N] N for(int i = 0;i < N; i++) {
					W[i] = sc.nextInt();
					S2 += W[i];
			} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
					W[i] = sc.nextInt();
					S2 += W[i];
			} {
					W[i] = sc.nextInt();
					S2 += W[i];
			} W[i] = sc.nextInt() W[i] W i sc.nextInt() sc.nextInt sc S2 += W[i] S2 W[i] W i for (int i = 0; i < N; i++ ){
					S1 += W[i];
					S2 -= W[i];
					if(S1 > S2){
							if(re > S1 - S2){
									re = S1 - S2;
							}
					}else {
							if(re > S2 - S1){
									re = S2 - S1;
							}
					}
			} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
					S1 += W[i];
					S2 -= W[i];
					if(S1 > S2){
							if(re > S1 - S2){
									re = S1 - S2;
							}
					}else {
							if(re > S2 - S1){
									re = S2 - S1;
							}
					}
			} {
					S1 += W[i];
					S2 -= W[i];
					if(S1 > S2){
							if(re > S1 - S2){
									re = S1 - S2;
							}
					}else {
							if(re > S2 - S1){
									re = S2 - S1;
							}
					}
			} S1 += W[i] S1 W[i] W i S2 -= W[i] S2 W[i] W i if(S1 > S2){
							if(re > S1 - S2){
									re = S1 - S2;
							}
					}else {
							if(re > S2 - S1){
									re = S2 - S1;
							}
					} S1 > S2 S1 S2 {
							if(re > S1 - S2){
									re = S1 - S2;
							}
					} if(re > S1 - S2){
									re = S1 - S2;
							} re > S1 - S2 re S1 - S2 S1 S2 {
									re = S1 - S2;
							} re = S1 - S2 re S1 - S2 S1 S2 {
							if(re > S2 - S1){
									re = S2 - S1;
							}
					} if(re > S2 - S1){
									re = S2 - S1;
							} re > S2 - S1 re S2 - S1 S2 S1 {
									re = S2 - S1;
							} re = S2 - S1 re S2 - S1 S2 S1 System.out.println(re) System.out.println System.out System System.out re String[] args args
import java.util.Scanner;

class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int N;
			int re = 9999999;
			int S1 = 0;
			int S2 = 0;
			int[] W;

			N = sc.nextInt();
			W = new int[N];
			for(int i = 0;i < N; i++) {
					W[i] = sc.nextInt();
					S2 += W[i];
			}

			for (int i = 0; i < N; i++ ){
					S1 += W[i];
					S2 -= W[i];
					if(S1 > S2){
							if(re > S1 - S2){
									re = S1 - S2;
							}
					}else {
							if(re > S2 - S1){
									re = S2 - S1;
							}
					}
			}
			System.out.println(re);
    }
}
