import java.util.*;

public class Main{
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int sum = 0;
		int[] W = new int[N];
		for(int i = 0; i < N; i++) {
			int x = sc.nextInt();
			W[i] = x;
			sum += x;
		}
		
		int now  = 0;
		int result = 0;
		for(int i = 0; i < N; i++) {
			if((now + W[i]) * 2 > sum) {
				result = Math.min(sum - now * 2, (now + W[i]) * 2 - sum);
				break;
			}
			now += W[i];
		}
		System.out.println(result);
	}
} 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 sum = 0;
		int[] W = new int[N];
		for(int i = 0; i < N; i++) {
			int x = sc.nextInt();
			W[i] = x;
			sum += x;
		}
		
		int now  = 0;
		int result = 0;
		for(int i = 0; i < N; i++) {
			if((now + W[i]) * 2 > sum) {
				result = Math.min(sum - now * 2, (now + W[i]) * 2 - sum);
				break;
			}
			now += W[i];
		}
		System.out.println(result);
	}
} Main public static void main(String args[]) {

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

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int sum = 0;
		int[] W = new int[N];
		for(int i = 0; i < N; i++) {
			int x = sc.nextInt();
			W[i] = x;
			sum += x;
		}
		
		int now  = 0;
		int result = 0;
		for(int i = 0; i < N; i++) {
			if((now + W[i]) * 2 > sum) {
				result = Math.min(sum - now * 2, (now + W[i]) * 2 - sum);
				break;
			}
			now += W[i];
		}
		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 sum = 0; sum 0 int[] W = new int[N]; W new int[N] N for(int i = 0; i < N; i++) {
			int x = sc.nextInt();
			W[i] = x;
			sum += x;
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			int x = sc.nextInt();
			W[i] = x;
			sum += x;
		} {
			int x = sc.nextInt();
			W[i] = x;
			sum += x;
		} int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc W[i] = x W[i] W i x sum += x sum x int now  = 0; now 0 int result = 0; result 0 for(int i = 0; i < N; i++) {
			if((now + W[i]) * 2 > sum) {
				result = Math.min(sum - now * 2, (now + W[i]) * 2 - sum);
				break;
			}
			now += W[i];
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			if((now + W[i]) * 2 > sum) {
				result = Math.min(sum - now * 2, (now + W[i]) * 2 - sum);
				break;
			}
			now += W[i];
		} {
			if((now + W[i]) * 2 > sum) {
				result = Math.min(sum - now * 2, (now + W[i]) * 2 - sum);
				break;
			}
			now += W[i];
		} if((now + W[i]) * 2 > sum) {
				result = Math.min(sum - now * 2, (now + W[i]) * 2 - sum);
				break;
			} (now + W[i]) * 2 > sum (now + W[i]) * 2 (now + W[i]) now W[i] W i 2 sum {
				result = Math.min(sum - now * 2, (now + W[i]) * 2 - sum);
				break;
			} result = Math.min(sum - now * 2, (now + W[i]) * 2 - sum) result Math.min(sum - now * 2, (now + W[i]) * 2 - sum) Math.min Math sum - now * 2 sum now * 2 now 2 (now + W[i]) * 2 - sum (now + W[i]) * 2 (now + W[i]) now W[i] W i 2 sum break; now += W[i] now W[i] W i 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 sum = 0;
		int[] W = new int[N];
		for(int i = 0; i < N; i++) {
			int x = sc.nextInt();
			W[i] = x;
			sum += x;
		}
		
		int now  = 0;
		int result = 0;
		for(int i = 0; i < N; i++) {
			if((now + W[i]) * 2 > sum) {
				result = Math.min(sum - now * 2, (now + W[i]) * 2 - sum);
				break;
			}
			now += W[i];
		}
		System.out.println(result);
	}
} public class Main{
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int sum = 0;
		int[] W = new int[N];
		for(int i = 0; i < N; i++) {
			int x = sc.nextInt();
			W[i] = x;
			sum += x;
		}
		
		int now  = 0;
		int result = 0;
		for(int i = 0; i < N; i++) {
			if((now + W[i]) * 2 > sum) {
				result = Math.min(sum - now * 2, (now + W[i]) * 2 - sum);
				break;
			}
			now += W[i];
		}
		System.out.println(result);
	}
} Main
import java.util.*;

public class Main{
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int sum = 0;
		int[] W = new int[N];
		for(int i = 0; i < N; i++) {
			int x = sc.nextInt();
			W[i] = x;
			sum += x;
		}
		
		int now  = 0;
		int result = 0;
		for(int i = 0; i < N; i++) {
			if((now + W[i]) * 2 > sum) {
				result = Math.min(sum - now * 2, (now + W[i]) * 2 - sum);
				break;
			}
			now += W[i];
		}
		System.out.println(result);
	}
}