import java.util.Arrays;
import java.util.Scanner;

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 < w.length; i++) {
			w[i] = sc.nextInt();
		}

		int[] sub = new int[n - 1];
		int idx = 0;
		for (int t = 1; t < w.length; t++) {
			int s1 = 0;
			for (int i = 0; i < t; i++) {
				s1 += w[i];
			}
			int s2 = 0;
			for (int i = t; i < w.length; i++) {
				s2 += w[i];
			}

			sub[idx++] = Math.abs(s1 - s2);
		}

		Arrays.sort(sub);

		System.out.println(sub[0]);
		sc.close();
	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util 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 < w.length; i++) {
			w[i] = sc.nextInt();
		}

		int[] sub = new int[n - 1];
		int idx = 0;
		for (int t = 1; t < w.length; t++) {
			int s1 = 0;
			for (int i = 0; i < t; i++) {
				s1 += w[i];
			}
			int s2 = 0;
			for (int i = t; i < w.length; i++) {
				s2 += w[i];
			}

			sub[idx++] = Math.abs(s1 - s2);
		}

		Arrays.sort(sub);

		System.out.println(sub[0]);
		sc.close();
	}
} 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 < w.length; i++) {
			w[i] = sc.nextInt();
		}

		int[] sub = new int[n - 1];
		int idx = 0;
		for (int t = 1; t < w.length; t++) {
			int s1 = 0;
			for (int i = 0; i < t; i++) {
				s1 += w[i];
			}
			int s2 = 0;
			for (int i = t; i < w.length; i++) {
				s2 += w[i];
			}

			sub[idx++] = Math.abs(s1 - s2);
		}

		Arrays.sort(sub);

		System.out.println(sub[0]);
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] w = new int[n];

		for (int i = 0; i < w.length; i++) {
			w[i] = sc.nextInt();
		}

		int[] sub = new int[n - 1];
		int idx = 0;
		for (int t = 1; t < w.length; t++) {
			int s1 = 0;
			for (int i = 0; i < t; i++) {
				s1 += w[i];
			}
			int s2 = 0;
			for (int i = t; i < w.length; i++) {
				s2 += w[i];
			}

			sub[idx++] = Math.abs(s1 - s2);
		}

		Arrays.sort(sub);

		System.out.println(sub[0]);
		sc.close();
	} 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 < w.length; i++) {
			w[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < w.length i w.length w w.length 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[] sub = new int[n - 1]; sub new int[n - 1] n - 1 n 1 int idx = 0; idx 0 for (int t = 1; t < w.length; t++) {
			int s1 = 0;
			for (int i = 0; i < t; i++) {
				s1 += w[i];
			}
			int s2 = 0;
			for (int i = t; i < w.length; i++) {
				s2 += w[i];
			}

			sub[idx++] = Math.abs(s1 - s2);
		} int t = 1; int t = 1; t 1 t < w.length t w.length w w.length t++ t++ t {
			int s1 = 0;
			for (int i = 0; i < t; i++) {
				s1 += w[i];
			}
			int s2 = 0;
			for (int i = t; i < w.length; i++) {
				s2 += w[i];
			}

			sub[idx++] = Math.abs(s1 - s2);
		} {
			int s1 = 0;
			for (int i = 0; i < t; i++) {
				s1 += w[i];
			}
			int s2 = 0;
			for (int i = t; i < w.length; i++) {
				s2 += w[i];
			}

			sub[idx++] = Math.abs(s1 - s2);
		} int s1 = 0; s1 0 for (int i = 0; i < t; i++) {
				s1 += w[i];
			} int i = 0; int i = 0; i 0 i < t i t i++ i++ i {
				s1 += w[i];
			} {
				s1 += w[i];
			} s1 += w[i] s1 w[i] w i int s2 = 0; s2 0 for (int i = t; i < w.length; i++) {
				s2 += w[i];
			} int i = t; int i = t; i t i < w.length i w.length w w.length i++ i++ i {
				s2 += w[i];
			} {
				s2 += w[i];
			} s2 += w[i] s2 w[i] w i sub[idx++] = Math.abs(s1 - s2) sub[idx++] sub idx++ idx Math.abs(s1 - s2) Math.abs Math s1 - s2 s1 s2 Arrays.sort(sub) Arrays.sort Arrays sub System.out.println(sub[0]) System.out.println System.out System System.out sub[0] sub 0 sc.close() sc.close sc String[] args args
import java.util.Arrays;
import java.util.Scanner;

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 < w.length; i++) {
			w[i] = sc.nextInt();
		}

		int[] sub = new int[n - 1];
		int idx = 0;
		for (int t = 1; t < w.length; t++) {
			int s1 = 0;
			for (int i = 0; i < t; i++) {
				s1 += w[i];
			}
			int s2 = 0;
			for (int i = t; i < w.length; i++) {
				s2 += w[i];
			}

			sub[idx++] = Math.abs(s1 - s2);
		}

		Arrays.sort(sub);

		System.out.println(sub[0]);
		sc.close();
	}
}
