import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;

	int max3(int a, int b, int c) {
		int max = ((a < b) ? b : a);
		return (max < c)? c : max;
	}
	
	void doIt() {
		int n = sc.nextInt();
		int w[] = new int[n + 1];
		w[0] = 0;
		for(int i = 1; i <= n; i++) {
			w[i] = w[i - 1];
			w[i] += sc.nextInt();
		}
		int min = MAX;
		for(int i = 0; i <= n; i++) {
			int val = Math.abs(w[n] - w[i] * 2); 
			min = (min > val) ? val : min;
		}
		System.out.println(min);
	}
	
	
	public static void main(String[] args) {
		new Main().doIt();
	}
} import java.util.*; util.* java public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;

	int max3(int a, int b, int c) {
		int max = ((a < b) ? b : a);
		return (max < c)? c : max;
	}
	
	void doIt() {
		int n = sc.nextInt();
		int w[] = new int[n + 1];
		w[0] = 0;
		for(int i = 1; i <= n; i++) {
			w[i] = w[i - 1];
			w[i] += sc.nextInt();
		}
		int min = MAX;
		for(int i = 0; i <= n; i++) {
			int val = Math.abs(w[n] - w[i] * 2); 
			min = (min > val) ? val : min;
		}
		System.out.println(min);
	}
	
	
	public static void main(String[] args) {
		new Main().doIt();
	}
} Main Scanner sc = new Scanner(System.in); sc new Scanner(System.in) final int MOD = 1000000007; MOD 1000000007 final int MAX = Integer.MAX_VALUE; MAX Integer.MAX_VALUE Integer Integer.MAX_VALUE final long LMAX = Long.MAX_VALUE; LMAX Long.MAX_VALUE Long Long.MAX_VALUE int max3(int a, int b, int c) {
		int max = ((a < b) ? b : a);
		return (max < c)? c : max;
	} max3 {
		int max = ((a < b) ? b : a);
		return (max < c)? c : max;
	} int max = ((a < b) ? b : a); max ((a < b) ? b : a) (a < b) a b b a return (max < c)? c : max; (max < c)? c : max (max < c) max c c max int a a int b b int c c void doIt() {
		int n = sc.nextInt();
		int w[] = new int[n + 1];
		w[0] = 0;
		for(int i = 1; i <= n; i++) {
			w[i] = w[i - 1];
			w[i] += sc.nextInt();
		}
		int min = MAX;
		for(int i = 0; i <= n; i++) {
			int val = Math.abs(w[n] - w[i] * 2); 
			min = (min > val) ? val : min;
		}
		System.out.println(min);
	} doIt {
		int n = sc.nextInt();
		int w[] = new int[n + 1];
		w[0] = 0;
		for(int i = 1; i <= n; i++) {
			w[i] = w[i - 1];
			w[i] += sc.nextInt();
		}
		int min = MAX;
		for(int i = 0; i <= n; i++) {
			int val = Math.abs(w[n] - w[i] * 2); 
			min = (min > val) ? val : min;
		}
		System.out.println(min);
	} int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int w[] = new int[n + 1]; w new int[n + 1] n + 1 n 1 w[0] = 0 w[0] w 0 0 for(int i = 1; i <= n; i++) {
			w[i] = w[i - 1];
			w[i] += sc.nextInt();
		} int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
			w[i] = w[i - 1];
			w[i] += sc.nextInt();
		} {
			w[i] = w[i - 1];
			w[i] += sc.nextInt();
		} w[i] = w[i - 1] w[i] w i w[i - 1] w i - 1 i 1 w[i] += sc.nextInt() w[i] w i sc.nextInt() sc.nextInt sc int min = MAX; min MAX for(int i = 0; i <= n; i++) {
			int val = Math.abs(w[n] - w[i] * 2); 
			min = (min > val) ? val : min;
		} int i = 0; int i = 0; i 0 i <= n i n i++ i++ i {
			int val = Math.abs(w[n] - w[i] * 2); 
			min = (min > val) ? val : min;
		} {
			int val = Math.abs(w[n] - w[i] * 2); 
			min = (min > val) ? val : min;
		} int val = Math.abs(w[n] - w[i] * 2); val Math.abs(w[n] - w[i] * 2) Math.abs Math w[n] - w[i] * 2 w[n] w n w[i] * 2 w[i] w i 2 min = (min > val) ? val : min min (min > val) ? val : min (min > val) min val val min System.out.println(min) System.out.println System.out System System.out min public static void main(String[] args) {
		new Main().doIt();
	} main {
		new Main().doIt();
	} new Main().doIt() new Main().doIt new Main() String[] args args public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;

	int max3(int a, int b, int c) {
		int max = ((a < b) ? b : a);
		return (max < c)? c : max;
	}
	
	void doIt() {
		int n = sc.nextInt();
		int w[] = new int[n + 1];
		w[0] = 0;
		for(int i = 1; i <= n; i++) {
			w[i] = w[i - 1];
			w[i] += sc.nextInt();
		}
		int min = MAX;
		for(int i = 0; i <= n; i++) {
			int val = Math.abs(w[n] - w[i] * 2); 
			min = (min > val) ? val : min;
		}
		System.out.println(min);
	}
	
	
	public static void main(String[] args) {
		new Main().doIt();
	}
} public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;

	int max3(int a, int b, int c) {
		int max = ((a < b) ? b : a);
		return (max < c)? c : max;
	}
	
	void doIt() {
		int n = sc.nextInt();
		int w[] = new int[n + 1];
		w[0] = 0;
		for(int i = 1; i <= n; i++) {
			w[i] = w[i - 1];
			w[i] += sc.nextInt();
		}
		int min = MAX;
		for(int i = 0; i <= n; i++) {
			int val = Math.abs(w[n] - w[i] * 2); 
			min = (min > val) ? val : min;
		}
		System.out.println(min);
	}
	
	
	public static void main(String[] args) {
		new Main().doIt();
	}
} Main
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;

	int max3(int a, int b, int c) {
		int max = ((a < b) ? b : a);
		return (max < c)? c : max;
	}
	
	void doIt() {
		int n = sc.nextInt();
		int w[] = new int[n + 1];
		w[0] = 0;
		for(int i = 1; i <= n; i++) {
			w[i] = w[i - 1];
			w[i] += sc.nextInt();
		}
		int min = MAX;
		for(int i = 0; i <= n; i++) {
			int val = Math.abs(w[n] - w[i] * 2); 
			min = (min > val) ? val : min;
		}
		System.out.println(min);
	}
	
	
	public static void main(String[] args) {
		new Main().doIt();
	}
}
