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];
		for(int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
		}
		int result = 0;
		for(int T = 1; T < N; T++) {
			int S1 = 0;
			int S2 = 0;
			for(int i = 0; i < N; i++) {
				if(i <= T - 1) {
					S1 += W[i];
				}else {
					S2 += W[i];
				}
			}
			if(T == 1) {
				result = Math.abs(S2 - S1);
			}
			result = Math.min(result, Math.abs(S2 - S1));
		}
		sc.close();
		System.out.println(result);
	}
} 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];
		for(int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
		}
		int result = 0;
		for(int T = 1; T < N; T++) {
			int S1 = 0;
			int S2 = 0;
			for(int i = 0; i < N; i++) {
				if(i <= T - 1) {
					S1 += W[i];
				}else {
					S2 += W[i];
				}
			}
			if(T == 1) {
				result = Math.abs(S2 - S1);
			}
			result = Math.min(result, Math.abs(S2 - S1));
		}
		sc.close();
		System.out.println(result);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] W = new int[N];
		for(int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
		}
		int result = 0;
		for(int T = 1; T < N; T++) {
			int S1 = 0;
			int S2 = 0;
			for(int i = 0; i < N; i++) {
				if(i <= T - 1) {
					S1 += W[i];
				}else {
					S2 += W[i];
				}
			}
			if(T == 1) {
				result = Math.abs(S2 - S1);
			}
			result = Math.min(result, Math.abs(S2 - S1));
		}
		sc.close();
		System.out.println(result);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] W = new int[N];
		for(int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
		}
		int result = 0;
		for(int T = 1; T < N; T++) {
			int S1 = 0;
			int S2 = 0;
			for(int i = 0; i < N; i++) {
				if(i <= T - 1) {
					S1 += W[i];
				}else {
					S2 += W[i];
				}
			}
			if(T == 1) {
				result = Math.abs(S2 - S1);
			}
			result = Math.min(result, Math.abs(S2 - S1));
		}
		sc.close();
		System.out.println(result);
	} 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 for(int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			W[i] = sc.nextInt();
		} {
			W[i] = sc.nextInt();
		} W[i] = sc.nextInt() W[i] W i sc.nextInt() sc.nextInt sc int result = 0; result 0 for(int T = 1; T < N; T++) {
			int S1 = 0;
			int S2 = 0;
			for(int i = 0; i < N; i++) {
				if(i <= T - 1) {
					S1 += W[i];
				}else {
					S2 += W[i];
				}
			}
			if(T == 1) {
				result = Math.abs(S2 - S1);
			}
			result = Math.min(result, Math.abs(S2 - S1));
		} int T = 1; int T = 1; T 1 T < N T N T++ T++ T {
			int S1 = 0;
			int S2 = 0;
			for(int i = 0; i < N; i++) {
				if(i <= T - 1) {
					S1 += W[i];
				}else {
					S2 += W[i];
				}
			}
			if(T == 1) {
				result = Math.abs(S2 - S1);
			}
			result = Math.min(result, Math.abs(S2 - S1));
		} {
			int S1 = 0;
			int S2 = 0;
			for(int i = 0; i < N; i++) {
				if(i <= T - 1) {
					S1 += W[i];
				}else {
					S2 += W[i];
				}
			}
			if(T == 1) {
				result = Math.abs(S2 - S1);
			}
			result = Math.min(result, Math.abs(S2 - S1));
		} int S1 = 0; S1 0 int S2 = 0; S2 0 for(int i = 0; i < N; i++) {
				if(i <= T - 1) {
					S1 += W[i];
				}else {
					S2 += W[i];
				}
			} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
				if(i <= T - 1) {
					S1 += W[i];
				}else {
					S2 += W[i];
				}
			} {
				if(i <= T - 1) {
					S1 += W[i];
				}else {
					S2 += W[i];
				}
			} if(i <= T - 1) {
					S1 += W[i];
				}else {
					S2 += W[i];
				} i <= T - 1 i T - 1 T 1 {
					S1 += W[i];
				} S1 += W[i] S1 W[i] W i {
					S2 += W[i];
				} S2 += W[i] S2 W[i] W i if(T == 1) {
				result = Math.abs(S2 - S1);
			} T == 1 T 1 {
				result = Math.abs(S2 - S1);
			} result = Math.abs(S2 - S1) result Math.abs(S2 - S1) Math.abs Math S2 - S1 S2 S1 result = Math.min(result, Math.abs(S2 - S1)) result Math.min(result, Math.abs(S2 - S1)) Math.min Math result Math.abs(S2 - S1) Math.abs Math S2 - S1 S2 S1 sc.close() sc.close sc System.out.println(result) System.out.println System.out System System.out result 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];
		for(int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
		}
		int result = 0;
		for(int T = 1; T < N; T++) {
			int S1 = 0;
			int S2 = 0;
			for(int i = 0; i < N; i++) {
				if(i <= T - 1) {
					S1 += W[i];
				}else {
					S2 += W[i];
				}
			}
			if(T == 1) {
				result = Math.abs(S2 - S1);
			}
			result = Math.min(result, Math.abs(S2 - S1));
		}
		sc.close();
		System.out.println(result);
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] W = new int[N];
		for(int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
		}
		int result = 0;
		for(int T = 1; T < N; T++) {
			int S1 = 0;
			int S2 = 0;
			for(int i = 0; i < N; i++) {
				if(i <= T - 1) {
					S1 += W[i];
				}else {
					S2 += W[i];
				}
			}
			if(T == 1) {
				result = Math.abs(S2 - S1);
			}
			result = Math.min(result, Math.abs(S2 - S1));
		}
		sc.close();
		System.out.println(result);
	}
} 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];
		for(int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
		}
		int result = 0;
		for(int T = 1; T < N; T++) {
			int S1 = 0;
			int S2 = 0;
			for(int i = 0; i < N; i++) {
				if(i <= T - 1) {
					S1 += W[i];
				}else {
					S2 += W[i];
				}
			}
			if(T == 1) {
				result = Math.abs(S2 - S1);
			}
			result = Math.min(result, Math.abs(S2 - S1));
		}
		sc.close();
		System.out.println(result);
	}
}