

import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String num = sc.nextLine();
		int N = Integer.parseInt(num);
		int[] W = new int[N];
		String line = sc.nextLine();
		String[] lines = line.split(" ");
		int S1 = 0;

		for(int i = 0; i < N; i++) {
			W[i] = Integer.parseInt(lines[i]);
			S1  = S1 + W[i];
		}

		S1 = S1 - W[N-1];
		int S2 = W[N-1];
		int min = 10000;

		for(int i = N-2; i > 0; i--) {
			int abs = Math.abs(S1 - S2);
			if(abs < min) {
				min = abs;
			}

			S1 = S1 - W[i];
			S2 = S2 + W[i];
		}


		System.out.println(min);
	}

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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String num = sc.nextLine();
		int N = Integer.parseInt(num);
		int[] W = new int[N];
		String line = sc.nextLine();
		String[] lines = line.split(" ");
		int S1 = 0;

		for(int i = 0; i < N; i++) {
			W[i] = Integer.parseInt(lines[i]);
			S1  = S1 + W[i];
		}

		S1 = S1 - W[N-1];
		int S2 = W[N-1];
		int min = 10000;

		for(int i = N-2; i > 0; i--) {
			int abs = Math.abs(S1 - S2);
			if(abs < min) {
				min = abs;
			}

			S1 = S1 - W[i];
			S2 = S2 + W[i];
		}


		System.out.println(min);
	}

} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String num = sc.nextLine();
		int N = Integer.parseInt(num);
		int[] W = new int[N];
		String line = sc.nextLine();
		String[] lines = line.split(" ");
		int S1 = 0;

		for(int i = 0; i < N; i++) {
			W[i] = Integer.parseInt(lines[i]);
			S1  = S1 + W[i];
		}

		S1 = S1 - W[N-1];
		int S2 = W[N-1];
		int min = 10000;

		for(int i = N-2; i > 0; i--) {
			int abs = Math.abs(S1 - S2);
			if(abs < min) {
				min = abs;
			}

			S1 = S1 - W[i];
			S2 = S2 + W[i];
		}


		System.out.println(min);
	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String num = sc.nextLine();
		int N = Integer.parseInt(num);
		int[] W = new int[N];
		String line = sc.nextLine();
		String[] lines = line.split(" ");
		int S1 = 0;

		for(int i = 0; i < N; i++) {
			W[i] = Integer.parseInt(lines[i]);
			S1  = S1 + W[i];
		}

		S1 = S1 - W[N-1];
		int S2 = W[N-1];
		int min = 10000;

		for(int i = N-2; i > 0; i--) {
			int abs = Math.abs(S1 - S2);
			if(abs < min) {
				min = abs;
			}

			S1 = S1 - W[i];
			S2 = S2 + W[i];
		}


		System.out.println(min);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String num = sc.nextLine(); num sc.nextLine() sc.nextLine sc int N = Integer.parseInt(num); N Integer.parseInt(num) Integer.parseInt Integer num int[] W = new int[N]; W new int[N] N String line = sc.nextLine(); line sc.nextLine() sc.nextLine sc String[] lines = line.split(" "); lines line.split(" ") line.split line " " int S1 = 0; S1 0 for(int i = 0; i < N; i++) {
			W[i] = Integer.parseInt(lines[i]);
			S1  = S1 + W[i];
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			W[i] = Integer.parseInt(lines[i]);
			S1  = S1 + W[i];
		} {
			W[i] = Integer.parseInt(lines[i]);
			S1  = S1 + W[i];
		} W[i] = Integer.parseInt(lines[i]) W[i] W i Integer.parseInt(lines[i]) Integer.parseInt Integer lines[i] lines i S1  = S1 + W[i] S1 S1 + W[i] S1 W[i] W i S1 = S1 - W[N-1] S1 S1 - W[N-1] S1 W[N-1] W N-1 N 1 int S2 = W[N-1]; S2 W[N-1] W N-1 N 1 int min = 10000; min 10000 for(int i = N-2; i > 0; i--) {
			int abs = Math.abs(S1 - S2);
			if(abs < min) {
				min = abs;
			}

			S1 = S1 - W[i];
			S2 = S2 + W[i];
		} int i = N-2; int i = N-2; i N-2 N 2 i > 0 i 0 i-- i-- i {
			int abs = Math.abs(S1 - S2);
			if(abs < min) {
				min = abs;
			}

			S1 = S1 - W[i];
			S2 = S2 + W[i];
		} {
			int abs = Math.abs(S1 - S2);
			if(abs < min) {
				min = abs;
			}

			S1 = S1 - W[i];
			S2 = S2 + W[i];
		} int abs = Math.abs(S1 - S2); abs Math.abs(S1 - S2) Math.abs Math S1 - S2 S1 S2 if(abs < min) {
				min = abs;
			} abs < min abs min {
				min = abs;
			} min = abs min abs S1 = S1 - W[i] S1 S1 - W[i] S1 W[i] W i S2 = S2 + W[i] S2 S2 + W[i] S2 W[i] W i 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) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String num = sc.nextLine();
		int N = Integer.parseInt(num);
		int[] W = new int[N];
		String line = sc.nextLine();
		String[] lines = line.split(" ");
		int S1 = 0;

		for(int i = 0; i < N; i++) {
			W[i] = Integer.parseInt(lines[i]);
			S1  = S1 + W[i];
		}

		S1 = S1 - W[N-1];
		int S2 = W[N-1];
		int min = 10000;

		for(int i = N-2; i > 0; i--) {
			int abs = Math.abs(S1 - S2);
			if(abs < min) {
				min = abs;
			}

			S1 = S1 - W[i];
			S2 = S2 + W[i];
		}


		System.out.println(min);
	}

} public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String num = sc.nextLine();
		int N = Integer.parseInt(num);
		int[] W = new int[N];
		String line = sc.nextLine();
		String[] lines = line.split(" ");
		int S1 = 0;

		for(int i = 0; i < N; i++) {
			W[i] = Integer.parseInt(lines[i]);
			S1  = S1 + W[i];
		}

		S1 = S1 - W[N-1];
		int S2 = W[N-1];
		int min = 10000;

		for(int i = N-2; i > 0; i--) {
			int abs = Math.abs(S1 - S2);
			if(abs < min) {
				min = abs;
			}

			S1 = S1 - W[i];
			S2 = S2 + W[i];
		}


		System.out.println(min);
	}

} Main


import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String num = sc.nextLine();
		int N = Integer.parseInt(num);
		int[] W = new int[N];
		String line = sc.nextLine();
		String[] lines = line.split(" ");
		int S1 = 0;

		for(int i = 0; i < N; i++) {
			W[i] = Integer.parseInt(lines[i]);
			S1  = S1 + W[i];
		}

		S1 = S1 - W[N-1];
		int S2 = W[N-1];
		int min = 10000;

		for(int i = N-2; i > 0; i--) {
			int abs = Math.abs(S1 - S2);
			if(abs < min) {
				min = abs;
			}

			S1 = S1 - W[i];
			S2 = S2 + W[i];
		}


		System.out.println(min);
	}

}
