
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int input[] = new int[n];
		int sum = 0;

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

		int minDiff = Integer.MAX_VALUE;
		int sum2 = 0;

		for(int i = 0; i < n - 1; i++){
			sum2 += input[i];
			int tmpDiff = Math.abs(sum - sum2*2);

			minDiff = Math.min(tmpDiff, minDiff);
		}

		System.out.println(minDiff);
	}

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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int input[] = new int[n];
		int sum = 0;

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

		int minDiff = Integer.MAX_VALUE;
		int sum2 = 0;

		for(int i = 0; i < n - 1; i++){
			sum2 += input[i];
			int tmpDiff = Math.abs(sum - sum2*2);

			minDiff = Math.min(tmpDiff, minDiff);
		}

		System.out.println(minDiff);
	}

} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int input[] = new int[n];
		int sum = 0;

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

		int minDiff = Integer.MAX_VALUE;
		int sum2 = 0;

		for(int i = 0; i < n - 1; i++){
			sum2 += input[i];
			int tmpDiff = Math.abs(sum - sum2*2);

			minDiff = Math.min(tmpDiff, minDiff);
		}

		System.out.println(minDiff);
	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int input[] = new int[n];
		int sum = 0;

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

		int minDiff = Integer.MAX_VALUE;
		int sum2 = 0;

		for(int i = 0; i < n - 1; i++){
			sum2 += input[i];
			int tmpDiff = Math.abs(sum - sum2*2);

			minDiff = Math.min(tmpDiff, minDiff);
		}

		System.out.println(minDiff);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int input[] = new int[n]; input new int[n] n int sum = 0; sum 0 for(int i = 0; i < n; i++){
			input[i] = sc.nextInt();
			sum += input[i];
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			input[i] = sc.nextInt();
			sum += input[i];
		} {
			input[i] = sc.nextInt();
			sum += input[i];
		} input[i] = sc.nextInt() input[i] input i sc.nextInt() sc.nextInt sc sum += input[i] sum input[i] input i int minDiff = Integer.MAX_VALUE; minDiff Integer.MAX_VALUE Integer Integer.MAX_VALUE int sum2 = 0; sum2 0 for(int i = 0; i < n - 1; i++){
			sum2 += input[i];
			int tmpDiff = Math.abs(sum - sum2*2);

			minDiff = Math.min(tmpDiff, minDiff);
		} int i = 0; int i = 0; i 0 i < n - 1 i n - 1 n 1 i++ i++ i {
			sum2 += input[i];
			int tmpDiff = Math.abs(sum - sum2*2);

			minDiff = Math.min(tmpDiff, minDiff);
		} {
			sum2 += input[i];
			int tmpDiff = Math.abs(sum - sum2*2);

			minDiff = Math.min(tmpDiff, minDiff);
		} sum2 += input[i] sum2 input[i] input i int tmpDiff = Math.abs(sum - sum2*2); tmpDiff Math.abs(sum - sum2*2) Math.abs Math sum - sum2*2 sum sum2*2 sum2 2 minDiff = Math.min(tmpDiff, minDiff) minDiff Math.min(tmpDiff, minDiff) Math.min Math tmpDiff minDiff System.out.println(minDiff) System.out.println System.out System System.out minDiff String[] args args public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int input[] = new int[n];
		int sum = 0;

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

		int minDiff = Integer.MAX_VALUE;
		int sum2 = 0;

		for(int i = 0; i < n - 1; i++){
			sum2 += input[i];
			int tmpDiff = Math.abs(sum - sum2*2);

			minDiff = Math.min(tmpDiff, minDiff);
		}

		System.out.println(minDiff);
	}

} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int input[] = new int[n];
		int sum = 0;

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

		int minDiff = Integer.MAX_VALUE;
		int sum2 = 0;

		for(int i = 0; i < n - 1; i++){
			sum2 += input[i];
			int tmpDiff = Math.abs(sum - sum2*2);

			minDiff = Math.min(tmpDiff, minDiff);
		}

		System.out.println(minDiff);
	}

} Main

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int input[] = new int[n];
		int sum = 0;

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

		int minDiff = Integer.MAX_VALUE;
		int sum2 = 0;

		for(int i = 0; i < n - 1; i++){
			sum2 += input[i];
			int tmpDiff = Math.abs(sum - sum2*2);

			minDiff = Math.min(tmpDiff, minDiff);
		}

		System.out.println(minDiff);
	}

}
