import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

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

		for (int i = 0; i < s1.length; i++) {
			sum += sc.nextInt();
			s1[i] = sum;
		}

		int minSub = sum;
		for (int t = 0; t < s1.length; t++) {
			int sub = Math.abs(sum - s1[t] * 2);
			if (sub < minSub)
				minSub = sub;
		}

		System.out.println(minSub);

		sc.close();
	}
} import java.util.Scanner; Scanner java.util class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

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

		for (int i = 0; i < s1.length; i++) {
			sum += sc.nextInt();
			s1[i] = sum;
		}

		int minSub = sum;
		for (int t = 0; t < s1.length; t++) {
			int sub = Math.abs(sum - s1[t] * 2);
			if (sub < minSub)
				minSub = sub;
		}

		System.out.println(minSub);

		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

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

		for (int i = 0; i < s1.length; i++) {
			sum += sc.nextInt();
			s1[i] = sum;
		}

		int minSub = sum;
		for (int t = 0; t < s1.length; t++) {
			int sub = Math.abs(sum - s1[t] * 2);
			if (sub < minSub)
				minSub = sub;
		}

		System.out.println(minSub);

		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);

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

		for (int i = 0; i < s1.length; i++) {
			sum += sc.nextInt();
			s1[i] = sum;
		}

		int minSub = sum;
		for (int t = 0; t < s1.length; t++) {
			int sub = Math.abs(sum - s1[t] * 2);
			if (sub < minSub)
				minSub = sub;
		}

		System.out.println(minSub);

		sc.close();
	} 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[] s1 = new int[n]; s1 new int[n] n for (int i = 0; i < s1.length; i++) {
			sum += sc.nextInt();
			s1[i] = sum;
		} int i = 0; int i = 0; i 0 i < s1.length i s1.length s1 s1.length i++ i++ i {
			sum += sc.nextInt();
			s1[i] = sum;
		} {
			sum += sc.nextInt();
			s1[i] = sum;
		} sum += sc.nextInt() sum sc.nextInt() sc.nextInt sc s1[i] = sum s1[i] s1 i sum int minSub = sum; minSub sum for (int t = 0; t < s1.length; t++) {
			int sub = Math.abs(sum - s1[t] * 2);
			if (sub < minSub)
				minSub = sub;
		} int t = 0; int t = 0; t 0 t < s1.length t s1.length s1 s1.length t++ t++ t {
			int sub = Math.abs(sum - s1[t] * 2);
			if (sub < minSub)
				minSub = sub;
		} {
			int sub = Math.abs(sum - s1[t] * 2);
			if (sub < minSub)
				minSub = sub;
		} int sub = Math.abs(sum - s1[t] * 2); sub Math.abs(sum - s1[t] * 2) Math.abs Math sum - s1[t] * 2 sum s1[t] * 2 s1[t] s1 t 2 if (sub < minSub)
				minSub = sub; sub < minSub sub minSub minSub = sub minSub sub System.out.println(minSub) System.out.println System.out System System.out minSub sc.close() sc.close sc String[] args args
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

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

		for (int i = 0; i < s1.length; i++) {
			sum += sc.nextInt();
			s1[i] = sum;
		}

		int minSub = sum;
		for (int t = 0; t < s1.length; t++) {
			int sub = Math.abs(sum - s1[t] * 2);
			if (sub < minSub)
				minSub = sub;
		}

		System.out.println(minSub);

		sc.close();
	}
}
