import 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];
		int sum = 0;
		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			sum += W[i];
		}
		sc.close();

		int now = 0;
		int prev = 0;
		for (int i = 0; i < N; i++) {
			now += W[i];

			if (now >= sum / 2) {
				prev = now - W[i];
				break;
			}
		}

		System.out.println(Math.min(Math.abs(sum - now * 2), Math.abs(sum - prev * 2)));
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] W = new int[N];
		int sum = 0;
		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			sum += W[i];
		}
		sc.close();

		int now = 0;
		int prev = 0;
		for (int i = 0; i < N; i++) {
			now += W[i];

			if (now >= sum / 2) {
				prev = now - W[i];
				break;
			}
		}

		System.out.println(Math.min(Math.abs(sum - now * 2), Math.abs(sum - prev * 2)));
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] W = new int[N];
		int sum = 0;
		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			sum += W[i];
		}
		sc.close();

		int now = 0;
		int prev = 0;
		for (int i = 0; i < N; i++) {
			now += W[i];

			if (now >= sum / 2) {
				prev = now - W[i];
				break;
			}
		}

		System.out.println(Math.min(Math.abs(sum - now * 2), Math.abs(sum - prev * 2)));
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] W = new int[N];
		int sum = 0;
		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			sum += W[i];
		}
		sc.close();

		int now = 0;
		int prev = 0;
		for (int i = 0; i < N; i++) {
			now += W[i];

			if (now >= sum / 2) {
				prev = now - W[i];
				break;
			}
		}

		System.out.println(Math.min(Math.abs(sum - now * 2), Math.abs(sum - prev * 2)));
	} 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 int sum = 0; sum 0 for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			sum += W[i];
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			W[i] = sc.nextInt();
			sum += W[i];
		} {
			W[i] = sc.nextInt();
			sum += W[i];
		} W[i] = sc.nextInt() W[i] W i sc.nextInt() sc.nextInt sc sum += W[i] sum W[i] W i sc.close() sc.close sc int now = 0; now 0 int prev = 0; prev 0 for (int i = 0; i < N; i++) {
			now += W[i];

			if (now >= sum / 2) {
				prev = now - W[i];
				break;
			}
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			now += W[i];

			if (now >= sum / 2) {
				prev = now - W[i];
				break;
			}
		} {
			now += W[i];

			if (now >= sum / 2) {
				prev = now - W[i];
				break;
			}
		} now += W[i] now W[i] W i if (now >= sum / 2) {
				prev = now - W[i];
				break;
			} now >= sum / 2 now sum / 2 sum 2 {
				prev = now - W[i];
				break;
			} prev = now - W[i] prev now - W[i] now W[i] W i break; System.out.println(Math.min(Math.abs(sum - now * 2), Math.abs(sum - prev * 2))) System.out.println System.out System System.out Math.min(Math.abs(sum - now * 2), Math.abs(sum - prev * 2)) Math.min Math Math.abs(sum - now * 2) Math.abs Math sum - now * 2 sum now * 2 now 2 Math.abs(sum - prev * 2) Math.abs Math sum - prev * 2 sum prev * 2 prev 2 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];
		int sum = 0;
		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			sum += W[i];
		}
		sc.close();

		int now = 0;
		int prev = 0;
		for (int i = 0; i < N; i++) {
			now += W[i];

			if (now >= sum / 2) {
				prev = now - W[i];
				break;
			}
		}

		System.out.println(Math.min(Math.abs(sum - now * 2), Math.abs(sum - prev * 2)));
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] W = new int[N];
		int sum = 0;
		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			sum += W[i];
		}
		sc.close();

		int now = 0;
		int prev = 0;
		for (int i = 0; i < N; i++) {
			now += W[i];

			if (now >= sum / 2) {
				prev = now - W[i];
				break;
			}
		}

		System.out.println(Math.min(Math.abs(sum - now * 2), Math.abs(sum - prev * 2)));
	}
} Main
import 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];
		int sum = 0;
		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			sum += W[i];
		}
		sc.close();

		int now = 0;
		int prev = 0;
		for (int i = 0; i < N; i++) {
			now += W[i];

			if (now >= sum / 2) {
				prev = now - W[i];
				break;
			}
		}

		System.out.println(Math.min(Math.abs(sum - now * 2), Math.abs(sum - prev * 2)));
	}
}
