import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] W = new int[N];
		for (int i = 0; i < N; i++) {
			W[i] = scan.nextInt();
		}
		int min = 10000;
		for (int i = 0; i < N; i++) {
			int S1 = 0;
			int S2 = 0;
			for (int j = 0; j < N; j++) {
				if (i <j) {
					S1 += W[j];
				} else {
					S2 += W[j];
				}
			}
			if (Math.abs(S1 - S2) < min) {
				min = Math.abs(S1 - S2);
			}
		}
		System.out.println(min);
	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] W = new int[N];
		for (int i = 0; i < N; i++) {
			W[i] = scan.nextInt();
		}
		int min = 10000;
		for (int i = 0; i < N; i++) {
			int S1 = 0;
			int S2 = 0;
			for (int j = 0; j < N; j++) {
				if (i <j) {
					S1 += W[j];
				} else {
					S2 += W[j];
				}
			}
			if (Math.abs(S1 - S2) < min) {
				min = Math.abs(S1 - S2);
			}
		}
		System.out.println(min);
	}

} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] W = new int[N];
		for (int i = 0; i < N; i++) {
			W[i] = scan.nextInt();
		}
		int min = 10000;
		for (int i = 0; i < N; i++) {
			int S1 = 0;
			int S2 = 0;
			for (int j = 0; j < N; j++) {
				if (i <j) {
					S1 += W[j];
				} else {
					S2 += W[j];
				}
			}
			if (Math.abs(S1 - S2) < min) {
				min = Math.abs(S1 - S2);
			}
		}
		System.out.println(min);
	} main {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] W = new int[N];
		for (int i = 0; i < N; i++) {
			W[i] = scan.nextInt();
		}
		int min = 10000;
		for (int i = 0; i < N; i++) {
			int S1 = 0;
			int S2 = 0;
			for (int j = 0; j < N; j++) {
				if (i <j) {
					S1 += W[j];
				} else {
					S2 += W[j];
				}
			}
			if (Math.abs(S1 - S2) < min) {
				min = Math.abs(S1 - S2);
			}
		}
		System.out.println(min);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan int[] W = new int[N]; W new int[N] N for (int i = 0; i < N; i++) {
			W[i] = scan.nextInt();
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			W[i] = scan.nextInt();
		} {
			W[i] = scan.nextInt();
		} W[i] = scan.nextInt() W[i] W i scan.nextInt() scan.nextInt scan int min = 10000; min 10000 for (int i = 0; i < N; i++) {
			int S1 = 0;
			int S2 = 0;
			for (int j = 0; j < N; j++) {
				if (i <j) {
					S1 += W[j];
				} else {
					S2 += W[j];
				}
			}
			if (Math.abs(S1 - S2) < min) {
				min = Math.abs(S1 - S2);
			}
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			int S1 = 0;
			int S2 = 0;
			for (int j = 0; j < N; j++) {
				if (i <j) {
					S1 += W[j];
				} else {
					S2 += W[j];
				}
			}
			if (Math.abs(S1 - S2) < min) {
				min = Math.abs(S1 - S2);
			}
		} {
			int S1 = 0;
			int S2 = 0;
			for (int j = 0; j < N; j++) {
				if (i <j) {
					S1 += W[j];
				} else {
					S2 += W[j];
				}
			}
			if (Math.abs(S1 - S2) < min) {
				min = Math.abs(S1 - S2);
			}
		} int S1 = 0; S1 0 int S2 = 0; S2 0 for (int j = 0; j < N; j++) {
				if (i <j) {
					S1 += W[j];
				} else {
					S2 += W[j];
				}
			} int j = 0; int j = 0; j 0 j < N j N j++ j++ j {
				if (i <j) {
					S1 += W[j];
				} else {
					S2 += W[j];
				}
			} {
				if (i <j) {
					S1 += W[j];
				} else {
					S2 += W[j];
				}
			} if (i <j) {
					S1 += W[j];
				} else {
					S2 += W[j];
				} i <j i j {
					S1 += W[j];
				} S1 += W[j] S1 W[j] W j {
					S2 += W[j];
				} S2 += W[j] S2 W[j] W j if (Math.abs(S1 - S2) < min) {
				min = Math.abs(S1 - S2);
			} Math.abs(S1 - S2) < min Math.abs(S1 - S2) Math.abs Math S1 - S2 S1 S2 min {
				min = Math.abs(S1 - S2);
			} min = Math.abs(S1 - S2) min Math.abs(S1 - S2) Math.abs Math S1 - S2 S1 S2 System.out.println(min) System.out.println System.out System System.out min String[] args args public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] W = new int[N];
		for (int i = 0; i < N; i++) {
			W[i] = scan.nextInt();
		}
		int min = 10000;
		for (int i = 0; i < N; i++) {
			int S1 = 0;
			int S2 = 0;
			for (int j = 0; j < N; j++) {
				if (i <j) {
					S1 += W[j];
				} else {
					S2 += W[j];
				}
			}
			if (Math.abs(S1 - S2) < min) {
				min = Math.abs(S1 - S2);
			}
		}
		System.out.println(min);
	}

} public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] W = new int[N];
		for (int i = 0; i < N; i++) {
			W[i] = scan.nextInt();
		}
		int min = 10000;
		for (int i = 0; i < N; i++) {
			int S1 = 0;
			int S2 = 0;
			for (int j = 0; j < N; j++) {
				if (i <j) {
					S1 += W[j];
				} else {
					S2 += W[j];
				}
			}
			if (Math.abs(S1 - S2) < min) {
				min = Math.abs(S1 - S2);
			}
		}
		System.out.println(min);
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] W = new int[N];
		for (int i = 0; i < N; i++) {
			W[i] = scan.nextInt();
		}
		int min = 10000;
		for (int i = 0; i < N; i++) {
			int S1 = 0;
			int S2 = 0;
			for (int j = 0; j < N; j++) {
				if (i <j) {
					S1 += W[j];
				} else {
					S2 += W[j];
				}
			}
			if (Math.abs(S1 - S2) < min) {
				min = Math.abs(S1 - S2);
			}
		}
		System.out.println(min);
	}

}
