import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		int N = in.nextInt();
		int[] W = new int[N];
		
		W[0] = in.nextInt();
		for(int i=1; i<N; i++) {
			W[i] = W[i-1]+in.nextInt();
			
		}
		
		int min = W[N-1];
		int sub;
		for(int i=0; i<N-1; i++) {
			sub = Math.abs(W[N-1] - W[i] - W[i]);
			if(sub < min) {
				min = sub;
			}else {
				break;
			}
		}
		System.out.println(min);
		in.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		int N = in.nextInt();
		int[] W = new int[N];
		
		W[0] = in.nextInt();
		for(int i=1; i<N; i++) {
			W[i] = W[i-1]+in.nextInt();
			
		}
		
		int min = W[N-1];
		int sub;
		for(int i=0; i<N-1; i++) {
			sub = Math.abs(W[N-1] - W[i] - W[i]);
			if(sub < min) {
				min = sub;
			}else {
				break;
			}
		}
		System.out.println(min);
		in.close();
	}
} Main public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		int N = in.nextInt();
		int[] W = new int[N];
		
		W[0] = in.nextInt();
		for(int i=1; i<N; i++) {
			W[i] = W[i-1]+in.nextInt();
			
		}
		
		int min = W[N-1];
		int sub;
		for(int i=0; i<N-1; i++) {
			sub = Math.abs(W[N-1] - W[i] - W[i]);
			if(sub < min) {
				min = sub;
			}else {
				break;
			}
		}
		System.out.println(min);
		in.close();
	} main {
		Scanner in = new java.util.Scanner(System.in);
		int N = in.nextInt();
		int[] W = new int[N];
		
		W[0] = in.nextInt();
		for(int i=1; i<N; i++) {
			W[i] = W[i-1]+in.nextInt();
			
		}
		
		int min = W[N-1];
		int sub;
		for(int i=0; i<N-1; i++) {
			sub = Math.abs(W[N-1] - W[i] - W[i]);
			if(sub < min) {
				min = sub;
			}else {
				break;
			}
		}
		System.out.println(min);
		in.close();
	} Scanner in = new java.util.Scanner(System.in); in new java.util.Scanner(System.in) int N = in.nextInt(); N in.nextInt() in.nextInt in int[] W = new int[N]; W new int[N] N W[0] = in.nextInt() W[0] W 0 in.nextInt() in.nextInt in for(int i=1; i<N; i++) {
			W[i] = W[i-1]+in.nextInt();
			
		} int i=1; int i=1; i 1 i<N i N i++ i++ i {
			W[i] = W[i-1]+in.nextInt();
			
		} {
			W[i] = W[i-1]+in.nextInt();
			
		} W[i] = W[i-1]+in.nextInt() W[i] W i W[i-1]+in.nextInt() W[i-1] W i-1 i 1 in.nextInt() in.nextInt in int min = W[N-1]; min W[N-1] W N-1 N 1 int sub; sub for(int i=0; i<N-1; i++) {
			sub = Math.abs(W[N-1] - W[i] - W[i]);
			if(sub < min) {
				min = sub;
			}else {
				break;
			}
		} int i=0; int i=0; i 0 i<N-1 i N-1 N 1 i++ i++ i {
			sub = Math.abs(W[N-1] - W[i] - W[i]);
			if(sub < min) {
				min = sub;
			}else {
				break;
			}
		} {
			sub = Math.abs(W[N-1] - W[i] - W[i]);
			if(sub < min) {
				min = sub;
			}else {
				break;
			}
		} sub = Math.abs(W[N-1] - W[i] - W[i]) sub Math.abs(W[N-1] - W[i] - W[i]) Math.abs Math W[N-1] - W[i] - W[i] W[N-1] - W[i] - W[i] W[N-1] W N-1 N 1 W[i] W i W[i] W i if(sub < min) {
				min = sub;
			}else {
				break;
			} sub < min sub min {
				min = sub;
			} min = sub min sub {
				break;
			} break; System.out.println(min) System.out.println System.out System System.out min in.close() in.close in String[] args args public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		int N = in.nextInt();
		int[] W = new int[N];
		
		W[0] = in.nextInt();
		for(int i=1; i<N; i++) {
			W[i] = W[i-1]+in.nextInt();
			
		}
		
		int min = W[N-1];
		int sub;
		for(int i=0; i<N-1; i++) {
			sub = Math.abs(W[N-1] - W[i] - W[i]);
			if(sub < min) {
				min = sub;
			}else {
				break;
			}
		}
		System.out.println(min);
		in.close();
	}
} public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		int N = in.nextInt();
		int[] W = new int[N];
		
		W[0] = in.nextInt();
		for(int i=1; i<N; i++) {
			W[i] = W[i-1]+in.nextInt();
			
		}
		
		int min = W[N-1];
		int sub;
		for(int i=0; i<N-1; i++) {
			sub = Math.abs(W[N-1] - W[i] - W[i]);
			if(sub < min) {
				min = sub;
			}else {
				break;
			}
		}
		System.out.println(min);
		in.close();
	}
} Main
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		int N = in.nextInt();
		int[] W = new int[N];
		
		W[0] = in.nextInt();
		for(int i=1; i<N; i++) {
			W[i] = W[i-1]+in.nextInt();
			
		}
		
		int min = W[N-1];
		int sub;
		for(int i=0; i<N-1; i++) {
			sub = Math.abs(W[N-1] - W[i] - W[i]);
			if(sub < min) {
				min = sub;
			}else {
				break;
			}
		}
		System.out.println(min);
		in.close();
	}
}
