import java.util.Scanner;

public class Main {

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

		int n = Integer.parseInt(sc.next());

		int[] num = new int[n];
		int total = 0;
		int left = 0;
		int min = 1000000000;

		for (int i = 0; i < n; i++) {
			num[i] = Integer.parseInt(sc.next());
			total += num[i];
		}

		for (int i = 0; i < n; i++) {
			left += num[i];
			if(Math.abs((total - left) - left) < min) {
				min = Math.abs((total-left) - left);
			}
		}

		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 = Integer.parseInt(sc.next());

		int[] num = new int[n];
		int total = 0;
		int left = 0;
		int min = 1000000000;

		for (int i = 0; i < n; i++) {
			num[i] = Integer.parseInt(sc.next());
			total += num[i];
		}

		for (int i = 0; i < n; i++) {
			left += num[i];
			if(Math.abs((total - left) - left) < min) {
				min = Math.abs((total-left) - left);
			}
		}

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

		int n = Integer.parseInt(sc.next());

		int[] num = new int[n];
		int total = 0;
		int left = 0;
		int min = 1000000000;

		for (int i = 0; i < n; i++) {
			num[i] = Integer.parseInt(sc.next());
			total += num[i];
		}

		for (int i = 0; i < n; i++) {
			left += num[i];
			if(Math.abs((total - left) - left) < min) {
				min = Math.abs((total-left) - left);
			}
		}

		System.out.println(min);
	} main {
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next());

		int[] num = new int[n];
		int total = 0;
		int left = 0;
		int min = 1000000000;

		for (int i = 0; i < n; i++) {
			num[i] = Integer.parseInt(sc.next());
			total += num[i];
		}

		for (int i = 0; i < n; i++) {
			left += num[i];
			if(Math.abs((total - left) - left) < min) {
				min = Math.abs((total-left) - left);
			}
		}

		System.out.println(min);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int[] num = new int[n]; num new int[n] n int total = 0; total 0 int left = 0; left 0 int min = 1000000000; min 1000000000 for (int i = 0; i < n; i++) {
			num[i] = Integer.parseInt(sc.next());
			total += num[i];
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			num[i] = Integer.parseInt(sc.next());
			total += num[i];
		} {
			num[i] = Integer.parseInt(sc.next());
			total += num[i];
		} num[i] = Integer.parseInt(sc.next()) num[i] num i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc total += num[i] total num[i] num i for (int i = 0; i < n; i++) {
			left += num[i];
			if(Math.abs((total - left) - left) < min) {
				min = Math.abs((total-left) - left);
			}
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			left += num[i];
			if(Math.abs((total - left) - left) < min) {
				min = Math.abs((total-left) - left);
			}
		} {
			left += num[i];
			if(Math.abs((total - left) - left) < min) {
				min = Math.abs((total-left) - left);
			}
		} left += num[i] left num[i] num i if(Math.abs((total - left) - left) < min) {
				min = Math.abs((total-left) - left);
			} Math.abs((total - left) - left) < min Math.abs((total - left) - left) Math.abs Math (total - left) - left (total - left) total left left min {
				min = Math.abs((total-left) - left);
			} min = Math.abs((total-left) - left) min Math.abs((total-left) - left) Math.abs Math (total-left) - left (total-left) total left left 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 = Integer.parseInt(sc.next());

		int[] num = new int[n];
		int total = 0;
		int left = 0;
		int min = 1000000000;

		for (int i = 0; i < n; i++) {
			num[i] = Integer.parseInt(sc.next());
			total += num[i];
		}

		for (int i = 0; i < n; i++) {
			left += num[i];
			if(Math.abs((total - left) - left) < min) {
				min = Math.abs((total-left) - left);
			}
		}

		System.out.println(min);
	}
} public class Main {

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

		int n = Integer.parseInt(sc.next());

		int[] num = new int[n];
		int total = 0;
		int left = 0;
		int min = 1000000000;

		for (int i = 0; i < n; i++) {
			num[i] = Integer.parseInt(sc.next());
			total += num[i];
		}

		for (int i = 0; i < n; i++) {
			left += num[i];
			if(Math.abs((total - left) - left) < min) {
				min = Math.abs((total-left) - left);
			}
		}

		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 = Integer.parseInt(sc.next());

		int[] num = new int[n];
		int total = 0;
		int left = 0;
		int min = 1000000000;

		for (int i = 0; i < n; i++) {
			num[i] = Integer.parseInt(sc.next());
			total += num[i];
		}

		for (int i = 0; i < n; i++) {
			left += num[i];
			if(Math.abs((total - left) - left) < min) {
				min = Math.abs((total-left) - left);
			}
		}

		System.out.println(min);
	}
}