import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		int total = 0;
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
			total += arr[i];
		}
		int min = Integer.MAX_VALUE;
		int sum = 0;
		for (int i = 0; i < n; i++) {
			sum += arr[i];
			int x = Math.abs(total - sum * 2);
			if (min > x) {
				min = x;
			}
		}
		System.out.println(min);
	}
} import java.util.*; util.* java public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		int total = 0;
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
			total += arr[i];
		}
		int min = Integer.MAX_VALUE;
		int sum = 0;
		for (int i = 0; i < n; i++) {
			sum += arr[i];
			int x = Math.abs(total - sum * 2);
			if (min > x) {
				min = x;
			}
		}
		System.out.println(min);
	}
} Main public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		int total = 0;
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
			total += arr[i];
		}
		int min = Integer.MAX_VALUE;
		int sum = 0;
		for (int i = 0; i < n; i++) {
			sum += arr[i];
			int x = Math.abs(total - sum * 2);
			if (min > x) {
				min = x;
			}
		}
		System.out.println(min);
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		int total = 0;
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
			total += arr[i];
		}
		int min = Integer.MAX_VALUE;
		int sum = 0;
		for (int i = 0; i < n; i++) {
			sum += arr[i];
			int x = Math.abs(total - sum * 2);
			if (min > x) {
				min = x;
			}
		}
		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[] arr = new int[n]; arr new int[n] n int total = 0; total 0 for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
			total += arr[i];
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			arr[i] = sc.nextInt();
			total += arr[i];
		} {
			arr[i] = sc.nextInt();
			total += arr[i];
		} arr[i] = sc.nextInt() arr[i] arr i sc.nextInt() sc.nextInt sc total += arr[i] total arr[i] arr i int min = Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE int sum = 0; sum 0 for (int i = 0; i < n; i++) {
			sum += arr[i];
			int x = Math.abs(total - sum * 2);
			if (min > x) {
				min = x;
			}
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			sum += arr[i];
			int x = Math.abs(total - sum * 2);
			if (min > x) {
				min = x;
			}
		} {
			sum += arr[i];
			int x = Math.abs(total - sum * 2);
			if (min > x) {
				min = x;
			}
		} sum += arr[i] sum arr[i] arr i int x = Math.abs(total - sum * 2); x Math.abs(total - sum * 2) Math.abs Math total - sum * 2 total sum * 2 sum 2 if (min > x) {
				min = x;
			} min > x min x {
				min = x;
			} min = x min x 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[] arr = new int[n];
		int total = 0;
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
			total += arr[i];
		}
		int min = Integer.MAX_VALUE;
		int sum = 0;
		for (int i = 0; i < n; i++) {
			sum += arr[i];
			int x = Math.abs(total - sum * 2);
			if (min > x) {
				min = x;
			}
		}
		System.out.println(min);
	}
} public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		int total = 0;
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
			total += arr[i];
		}
		int min = Integer.MAX_VALUE;
		int sum = 0;
		for (int i = 0; i < n; i++) {
			sum += arr[i];
			int x = Math.abs(total - sum * 2);
			if (min > x) {
				min = x;
			}
		}
		System.out.println(min);
	}
} Main
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		int total = 0;
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
			total += arr[i];
		}
		int min = Integer.MAX_VALUE;
		int sum = 0;
		for (int i = 0; i < n; i++) {
			sum += arr[i];
			int x = Math.abs(total - sum * 2);
			if (min > x) {
				min = x;
			}
		}
		System.out.println(min);
	}
}
