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];

		int sumAll = 0;
		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			sumAll += W[i];
		}

		int answer = 0;
		int id = 0;
		for (int i = 0; i < N; i++) {
			answer += W[i];
			id = i;
			if (answer > sumAll / 2.0)
				break;
		}
		if (Math.abs(sumAll - 2 * answer) > Math.abs(sumAll - 2 * (answer - W[id])))
			System.out.println(Math.abs(sumAll - 2 * (answer - W[id])));
		else
			System.out.println(Math.abs(sumAll - 2 * answer));
		sc.close();
	}
} 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];

		int sumAll = 0;
		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			sumAll += W[i];
		}

		int answer = 0;
		int id = 0;
		for (int i = 0; i < N; i++) {
			answer += W[i];
			id = i;
			if (answer > sumAll / 2.0)
				break;
		}
		if (Math.abs(sumAll - 2 * answer) > Math.abs(sumAll - 2 * (answer - W[id])))
			System.out.println(Math.abs(sumAll - 2 * (answer - W[id])));
		else
			System.out.println(Math.abs(sumAll - 2 * answer));
		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] W = new int[N];

		int sumAll = 0;
		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			sumAll += W[i];
		}

		int answer = 0;
		int id = 0;
		for (int i = 0; i < N; i++) {
			answer += W[i];
			id = i;
			if (answer > sumAll / 2.0)
				break;
		}
		if (Math.abs(sumAll - 2 * answer) > Math.abs(sumAll - 2 * (answer - W[id])))
			System.out.println(Math.abs(sumAll - 2 * (answer - W[id])));
		else
			System.out.println(Math.abs(sumAll - 2 * answer));
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] W = new int[N];

		int sumAll = 0;
		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			sumAll += W[i];
		}

		int answer = 0;
		int id = 0;
		for (int i = 0; i < N; i++) {
			answer += W[i];
			id = i;
			if (answer > sumAll / 2.0)
				break;
		}
		if (Math.abs(sumAll - 2 * answer) > Math.abs(sumAll - 2 * (answer - W[id])))
			System.out.println(Math.abs(sumAll - 2 * (answer - W[id])));
		else
			System.out.println(Math.abs(sumAll - 2 * answer));
		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 int sumAll = 0; sumAll 0 for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			sumAll += W[i];
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			W[i] = sc.nextInt();
			sumAll += W[i];
		} {
			W[i] = sc.nextInt();
			sumAll += W[i];
		} W[i] = sc.nextInt() W[i] W i sc.nextInt() sc.nextInt sc sumAll += W[i] sumAll W[i] W i int answer = 0; answer 0 int id = 0; id 0 for (int i = 0; i < N; i++) {
			answer += W[i];
			id = i;
			if (answer > sumAll / 2.0)
				break;
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			answer += W[i];
			id = i;
			if (answer > sumAll / 2.0)
				break;
		} {
			answer += W[i];
			id = i;
			if (answer > sumAll / 2.0)
				break;
		} answer += W[i] answer W[i] W i id = i id i if (answer > sumAll / 2.0)
				break; answer > sumAll / 2.0 answer sumAll / 2.0 sumAll 2.0 break; if (Math.abs(sumAll - 2 * answer) > Math.abs(sumAll - 2 * (answer - W[id])))
			System.out.println(Math.abs(sumAll - 2 * (answer - W[id])));
		else
			System.out.println(Math.abs(sumAll - 2 * answer)); Math.abs(sumAll - 2 * answer) > Math.abs(sumAll - 2 * (answer - W[id])) Math.abs(sumAll - 2 * answer) Math.abs Math sumAll - 2 * answer sumAll 2 * answer 2 answer Math.abs(sumAll - 2 * (answer - W[id])) Math.abs Math sumAll - 2 * (answer - W[id]) sumAll 2 * (answer - W[id]) 2 (answer - W[id]) answer W[id] W id System.out.println(Math.abs(sumAll - 2 * (answer - W[id]))) System.out.println System.out System System.out Math.abs(sumAll - 2 * (answer - W[id])) Math.abs Math sumAll - 2 * (answer - W[id]) sumAll 2 * (answer - W[id]) 2 (answer - W[id]) answer W[id] W id System.out.println(Math.abs(sumAll - 2 * answer)) System.out.println System.out System System.out Math.abs(sumAll - 2 * answer) Math.abs Math sumAll - 2 * answer sumAll 2 * answer 2 answer sc.close() sc.close sc 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 sumAll = 0;
		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			sumAll += W[i];
		}

		int answer = 0;
		int id = 0;
		for (int i = 0; i < N; i++) {
			answer += W[i];
			id = i;
			if (answer > sumAll / 2.0)
				break;
		}
		if (Math.abs(sumAll - 2 * answer) > Math.abs(sumAll - 2 * (answer - W[id])))
			System.out.println(Math.abs(sumAll - 2 * (answer - W[id])));
		else
			System.out.println(Math.abs(sumAll - 2 * answer));
		sc.close();
	}
} 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 sumAll = 0;
		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			sumAll += W[i];
		}

		int answer = 0;
		int id = 0;
		for (int i = 0; i < N; i++) {
			answer += W[i];
			id = i;
			if (answer > sumAll / 2.0)
				break;
		}
		if (Math.abs(sumAll - 2 * answer) > Math.abs(sumAll - 2 * (answer - W[id])))
			System.out.println(Math.abs(sumAll - 2 * (answer - W[id])));
		else
			System.out.println(Math.abs(sumAll - 2 * answer));
		sc.close();
	}
} 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];

		int sumAll = 0;
		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			sumAll += W[i];
		}

		int answer = 0;
		int id = 0;
		for (int i = 0; i < N; i++) {
			answer += W[i];
			id = i;
			if (answer > sumAll / 2.0)
				break;
		}
		if (Math.abs(sumAll - 2 * answer) > Math.abs(sumAll - 2 * (answer - W[id])))
			System.out.println(Math.abs(sumAll - 2 * (answer - W[id])));
		else
			System.out.println(Math.abs(sumAll - 2 * answer));
		sc.close();
	}
}
