import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		List<Integer> mark = new ArrayList<>();
		int sum = 0;

		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		for (int i = 0; i < n; i++) {
			int a = Integer.parseInt(sc.next());
			sum += a;
			mark.add(sum);
		}
		int be;
		int ans = sum;
		for (int p : mark) {

			be = sum - p;
			if (Math.abs(be - p) < ans) {
				ans = Math.abs(be - p);
			}
		}
		System.out.println(ans);
	}

} import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		List<Integer> mark = new ArrayList<>();
		int sum = 0;

		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		for (int i = 0; i < n; i++) {
			int a = Integer.parseInt(sc.next());
			sum += a;
			mark.add(sum);
		}
		int be;
		int ans = sum;
		for (int p : mark) {

			be = sum - p;
			if (Math.abs(be - p) < ans) {
				ans = Math.abs(be - p);
			}
		}
		System.out.println(ans);
	}

} Main public static void main(String[] args) {
		List<Integer> mark = new ArrayList<>();
		int sum = 0;

		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		for (int i = 0; i < n; i++) {
			int a = Integer.parseInt(sc.next());
			sum += a;
			mark.add(sum);
		}
		int be;
		int ans = sum;
		for (int p : mark) {

			be = sum - p;
			if (Math.abs(be - p) < ans) {
				ans = Math.abs(be - p);
			}
		}
		System.out.println(ans);
	} main {
		List<Integer> mark = new ArrayList<>();
		int sum = 0;

		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		for (int i = 0; i < n; i++) {
			int a = Integer.parseInt(sc.next());
			sum += a;
			mark.add(sum);
		}
		int be;
		int ans = sum;
		for (int p : mark) {

			be = sum - p;
			if (Math.abs(be - p) < ans) {
				ans = Math.abs(be - p);
			}
		}
		System.out.println(ans);
	} List<Integer> mark = new ArrayList<>(); mark new ArrayList<>() int sum = 0; sum 0 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 for (int i = 0; i < n; i++) {
			int a = Integer.parseInt(sc.next());
			sum += a;
			mark.add(sum);
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			int a = Integer.parseInt(sc.next());
			sum += a;
			mark.add(sum);
		} {
			int a = Integer.parseInt(sc.next());
			sum += a;
			mark.add(sum);
		} int a = Integer.parseInt(sc.next()); a Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc sum += a sum a mark.add(sum) mark.add mark sum int be; be int ans = sum; ans sum for (int p : mark) {

			be = sum - p;
			if (Math.abs(be - p) < ans) {
				ans = Math.abs(be - p);
			}
		} int p mark {

			be = sum - p;
			if (Math.abs(be - p) < ans) {
				ans = Math.abs(be - p);
			}
		} {

			be = sum - p;
			if (Math.abs(be - p) < ans) {
				ans = Math.abs(be - p);
			}
		} be = sum - p be sum - p sum p if (Math.abs(be - p) < ans) {
				ans = Math.abs(be - p);
			} Math.abs(be - p) < ans Math.abs(be - p) Math.abs Math be - p be p ans {
				ans = Math.abs(be - p);
			} ans = Math.abs(be - p) ans Math.abs(be - p) Math.abs Math be - p be p 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) {
		List<Integer> mark = new ArrayList<>();
		int sum = 0;

		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		for (int i = 0; i < n; i++) {
			int a = Integer.parseInt(sc.next());
			sum += a;
			mark.add(sum);
		}
		int be;
		int ans = sum;
		for (int p : mark) {

			be = sum - p;
			if (Math.abs(be - p) < ans) {
				ans = Math.abs(be - p);
			}
		}
		System.out.println(ans);
	}

} public class Main {

	public static void main(String[] args) {
		List<Integer> mark = new ArrayList<>();
		int sum = 0;

		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		for (int i = 0; i < n; i++) {
			int a = Integer.parseInt(sc.next());
			sum += a;
			mark.add(sum);
		}
		int be;
		int ans = sum;
		for (int p : mark) {

			be = sum - p;
			if (Math.abs(be - p) < ans) {
				ans = Math.abs(be - p);
			}
		}
		System.out.println(ans);
	}

} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		List<Integer> mark = new ArrayList<>();
		int sum = 0;

		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		for (int i = 0; i < n; i++) {
			int a = Integer.parseInt(sc.next());
			sum += a;
			mark.add(sum);
		}
		int be;
		int ans = sum;
		for (int p : mark) {

			be = sum - p;
			if (Math.abs(be - p) < ans) {
				ans = Math.abs(be - p);
			}
		}
		System.out.println(ans);
	}

}
