
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 s = 0;
		int[] sum = new int[n];

		for (int i = 0; i < n; i++) {
			w[i] = sc.nextInt();
			s += w[i];
			sum[i] = s;
		}

		int min = 10000;

		for (int i = 0; i < n; i++) {
			min = Math.min(min, Math.abs(s - 2 * sum[i]));
		}

		System.out.println(min);
	}

} 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 s = 0;
		int[] sum = new int[n];

		for (int i = 0; i < n; i++) {
			w[i] = sc.nextInt();
			s += w[i];
			sum[i] = s;
		}

		int min = 10000;

		for (int i = 0; i < n; i++) {
			min = Math.min(min, Math.abs(s - 2 * sum[i]));
		}

		System.out.println(min);
	}

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

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] w = new int[n];
		int s = 0;
		int[] sum = new int[n];

		for (int i = 0; i < n; i++) {
			w[i] = sc.nextInt();
			s += w[i];
			sum[i] = s;
		}

		int min = 10000;

		for (int i = 0; i < n; i++) {
			min = Math.min(min, Math.abs(s - 2 * sum[i]));
		}

		System.out.println(min);
	} main {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] w = new int[n];
		int s = 0;
		int[] sum = new int[n];

		for (int i = 0; i < n; i++) {
			w[i] = sc.nextInt();
			s += w[i];
			sum[i] = s;
		}

		int min = 10000;

		for (int i = 0; i < n; i++) {
			min = Math.min(min, Math.abs(s - 2 * sum[i]));
		}

		System.out.println(min);
	} 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 s = 0; s 0 int[] sum = new int[n]; sum new int[n] n for (int i = 0; i < n; i++) {
			w[i] = sc.nextInt();
			s += w[i];
			sum[i] = s;
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			w[i] = sc.nextInt();
			s += w[i];
			sum[i] = s;
		} {
			w[i] = sc.nextInt();
			s += w[i];
			sum[i] = s;
		} w[i] = sc.nextInt() w[i] w i sc.nextInt() sc.nextInt sc s += w[i] s w[i] w i sum[i] = s sum[i] sum i s int min = 10000; min 10000 for (int i = 0; i < n; i++) {
			min = Math.min(min, Math.abs(s - 2 * sum[i]));
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			min = Math.min(min, Math.abs(s - 2 * sum[i]));
		} {
			min = Math.min(min, Math.abs(s - 2 * sum[i]));
		} min = Math.min(min, Math.abs(s - 2 * sum[i])) min Math.min(min, Math.abs(s - 2 * sum[i])) Math.min Math min Math.abs(s - 2 * sum[i]) Math.abs Math s - 2 * sum[i] s 2 * sum[i] 2 sum[i] sum i 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 sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] w = new int[n];
		int s = 0;
		int[] sum = new int[n];

		for (int i = 0; i < n; i++) {
			w[i] = sc.nextInt();
			s += w[i];
			sum[i] = s;
		}

		int min = 10000;

		for (int i = 0; i < n; i++) {
			min = Math.min(min, Math.abs(s - 2 * sum[i]));
		}

		System.out.println(min);
	}

} 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 s = 0;
		int[] sum = new int[n];

		for (int i = 0; i < n; i++) {
			w[i] = sc.nextInt();
			s += w[i];
			sum[i] = s;
		}

		int min = 10000;

		for (int i = 0; i < n; i++) {
			min = Math.min(min, Math.abs(s - 2 * sum[i]));
		}

		System.out.println(min);
	}

} 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 s = 0;
		int[] sum = new int[n];

		for (int i = 0; i < n; i++) {
			w[i] = sc.nextInt();
			s += w[i];
			sum[i] = s;
		}

		int min = 10000;

		for (int i = 0; i < n; i++) {
			min = Math.min(min, Math.abs(s - 2 * sum[i]));
		}

		System.out.println(min);
	}

}
