import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int res = Integer.MAX_VALUE;
		int N = scan.nextInt();
		int as[] = new int[N + 1];
		as[0] = 0;

		for(int i = 1; i <= N; i++) {
			as[i] = as[i - 1] + scan.nextInt();
		}

		for(int i = 1; i < N; i++) {
			res = Math.min(res, Math.abs(2 * as[i] - as[N]));
		}

		System.out.println(res);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int res = Integer.MAX_VALUE;
		int N = scan.nextInt();
		int as[] = new int[N + 1];
		as[0] = 0;

		for(int i = 1; i <= N; i++) {
			as[i] = as[i - 1] + scan.nextInt();
		}

		for(int i = 1; i < N; i++) {
			res = Math.min(res, Math.abs(2 * as[i] - as[N]));
		}

		System.out.println(res);
	}
} Main public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int res = Integer.MAX_VALUE;
		int N = scan.nextInt();
		int as[] = new int[N + 1];
		as[0] = 0;

		for(int i = 1; i <= N; i++) {
			as[i] = as[i - 1] + scan.nextInt();
		}

		for(int i = 1; i < N; i++) {
			res = Math.min(res, Math.abs(2 * as[i] - as[N]));
		}

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

		Scanner scan = new Scanner(System.in);

		int res = Integer.MAX_VALUE;
		int N = scan.nextInt();
		int as[] = new int[N + 1];
		as[0] = 0;

		for(int i = 1; i <= N; i++) {
			as[i] = as[i - 1] + scan.nextInt();
		}

		for(int i = 1; i < N; i++) {
			res = Math.min(res, Math.abs(2 * as[i] - as[N]));
		}

		System.out.println(res);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int res = Integer.MAX_VALUE; res Integer.MAX_VALUE Integer Integer.MAX_VALUE int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan int as[] = new int[N + 1]; as new int[N + 1] N + 1 N 1 as[0] = 0 as[0] as 0 0 for(int i = 1; i <= N; i++) {
			as[i] = as[i - 1] + scan.nextInt();
		} int i = 1; int i = 1; i 1 i <= N i N i++ i++ i {
			as[i] = as[i - 1] + scan.nextInt();
		} {
			as[i] = as[i - 1] + scan.nextInt();
		} as[i] = as[i - 1] + scan.nextInt() as[i] as i as[i - 1] + scan.nextInt() as[i - 1] as i - 1 i 1 scan.nextInt() scan.nextInt scan for(int i = 1; i < N; i++) {
			res = Math.min(res, Math.abs(2 * as[i] - as[N]));
		} int i = 1; int i = 1; i 1 i < N i N i++ i++ i {
			res = Math.min(res, Math.abs(2 * as[i] - as[N]));
		} {
			res = Math.min(res, Math.abs(2 * as[i] - as[N]));
		} res = Math.min(res, Math.abs(2 * as[i] - as[N])) res Math.min(res, Math.abs(2 * as[i] - as[N])) Math.min Math res Math.abs(2 * as[i] - as[N]) Math.abs Math 2 * as[i] - as[N] 2 * as[i] 2 as[i] as i as[N] as N System.out.println(res) System.out.println System.out System System.out res String[] args args public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int res = Integer.MAX_VALUE;
		int N = scan.nextInt();
		int as[] = new int[N + 1];
		as[0] = 0;

		for(int i = 1; i <= N; i++) {
			as[i] = as[i - 1] + scan.nextInt();
		}

		for(int i = 1; i < N; i++) {
			res = Math.min(res, Math.abs(2 * as[i] - as[N]));
		}

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

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int res = Integer.MAX_VALUE;
		int N = scan.nextInt();
		int as[] = new int[N + 1];
		as[0] = 0;

		for(int i = 1; i <= N; i++) {
			as[i] = as[i - 1] + scan.nextInt();
		}

		for(int i = 1; i < N; i++) {
			res = Math.min(res, Math.abs(2 * as[i] - as[N]));
		}

		System.out.println(res);
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int res = Integer.MAX_VALUE;
		int N = scan.nextInt();
		int as[] = new int[N + 1];
		as[0] = 0;

		for(int i = 1; i <= N; i++) {
			as[i] = as[i - 1] + scan.nextInt();
		}

		for(int i = 1; i < N; i++) {
			res = Math.min(res, Math.abs(2 * as[i] - as[N]));
		}

		System.out.println(res);
	}
}