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

		int ans = 9999999;
		int sum2 = 0;
		for (int i = 0; i < N; i++) {
			sum2 += W[i];
			int sum3 = sum - sum2;
			if (ans > Math.abs(sum3 - sum2)) {
				ans = Math.abs(sum3 - sum2);
			}
		}
		System.out.println(ans);
	}
} 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 sum = 0;
		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			sum += W[i];
		}
		sc.close();

		int ans = 9999999;
		int sum2 = 0;
		for (int i = 0; i < N; i++) {
			sum2 += W[i];
			int sum3 = sum - sum2;
			if (ans > Math.abs(sum3 - sum2)) {
				ans = Math.abs(sum3 - sum2);
			}
		}
		System.out.println(ans);
	}
} 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 ans = 9999999;
		int sum2 = 0;
		for (int i = 0; i < N; i++) {
			sum2 += W[i];
			int sum3 = sum - sum2;
			if (ans > Math.abs(sum3 - sum2)) {
				ans = Math.abs(sum3 - sum2);
			}
		}
		System.out.println(ans);
	} 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 ans = 9999999;
		int sum2 = 0;
		for (int i = 0; i < N; i++) {
			sum2 += W[i];
			int sum3 = sum - sum2;
			if (ans > Math.abs(sum3 - sum2)) {
				ans = Math.abs(sum3 - sum2);
			}
		}
		System.out.println(ans);
	} 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 ans = 9999999; ans 9999999 int sum2 = 0; sum2 0 for (int i = 0; i < N; i++) {
			sum2 += W[i];
			int sum3 = sum - sum2;
			if (ans > Math.abs(sum3 - sum2)) {
				ans = Math.abs(sum3 - sum2);
			}
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			sum2 += W[i];
			int sum3 = sum - sum2;
			if (ans > Math.abs(sum3 - sum2)) {
				ans = Math.abs(sum3 - sum2);
			}
		} {
			sum2 += W[i];
			int sum3 = sum - sum2;
			if (ans > Math.abs(sum3 - sum2)) {
				ans = Math.abs(sum3 - sum2);
			}
		} sum2 += W[i] sum2 W[i] W i int sum3 = sum - sum2; sum3 sum - sum2 sum sum2 if (ans > Math.abs(sum3 - sum2)) {
				ans = Math.abs(sum3 - sum2);
			} ans > Math.abs(sum3 - sum2) ans Math.abs(sum3 - sum2) Math.abs Math sum3 - sum2 sum3 sum2 {
				ans = Math.abs(sum3 - sum2);
			} ans = Math.abs(sum3 - sum2) ans Math.abs(sum3 - sum2) Math.abs Math sum3 - sum2 sum3 sum2 System.out.println(ans) System.out.println System.out System System.out ans 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 ans = 9999999;
		int sum2 = 0;
		for (int i = 0; i < N; i++) {
			sum2 += W[i];
			int sum3 = sum - sum2;
			if (ans > Math.abs(sum3 - sum2)) {
				ans = Math.abs(sum3 - sum2);
			}
		}
		System.out.println(ans);
	}
} 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 ans = 9999999;
		int sum2 = 0;
		for (int i = 0; i < N; i++) {
			sum2 += W[i];
			int sum3 = sum - sum2;
			if (ans > Math.abs(sum3 - sum2)) {
				ans = Math.abs(sum3 - sum2);
			}
		}
		System.out.println(ans);
	}
} 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 sum = 0;
		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			sum += W[i];
		}
		sc.close();

		int ans = 9999999;
		int sum2 = 0;
		for (int i = 0; i < N; i++) {
			sum2 += W[i];
			int sum3 = sum - sum2;
			if (ans > Math.abs(sum3 - sum2)) {
				ans = Math.abs(sum3 - sum2);
			}
		}
		System.out.println(ans);
	}
}
