import java.util.Scanner;

public class Main {
	public static void main(String arg[]) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int W[] = new int[N];
		int a = 0;
		int b = 0;
		int sumW = 0;
		int min = 1000000;

		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			sumW += W[i];
		}

		for (int i = 0; i < N - 1; i++) {
			a += W[i];
			b = sumW - a;

			if (min >= Math.abs(a-b)) {
				min = Math.abs(a-b);
			}
		}

		System.out.print(min);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String arg[]) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int W[] = new int[N];
		int a = 0;
		int b = 0;
		int sumW = 0;
		int min = 1000000;

		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			sumW += W[i];
		}

		for (int i = 0; i < N - 1; i++) {
			a += W[i];
			b = sumW - a;

			if (min >= Math.abs(a-b)) {
				min = Math.abs(a-b);
			}
		}

		System.out.print(min);
	}
} Main public static void main(String arg[]) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int W[] = new int[N];
		int a = 0;
		int b = 0;
		int sumW = 0;
		int min = 1000000;

		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			sumW += W[i];
		}

		for (int i = 0; i < N - 1; i++) {
			a += W[i];
			b = sumW - a;

			if (min >= Math.abs(a-b)) {
				min = Math.abs(a-b);
			}
		}

		System.out.print(min);
	} main {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int W[] = new int[N];
		int a = 0;
		int b = 0;
		int sumW = 0;
		int min = 1000000;

		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			sumW += W[i];
		}

		for (int i = 0; i < N - 1; i++) {
			a += W[i];
			b = sumW - a;

			if (min >= Math.abs(a-b)) {
				min = Math.abs(a-b);
			}
		}

		System.out.print(min);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int W[] = new int[N]; W new int[N] N int a = 0; a 0 int b = 0; b 0 int sumW = 0; sumW 0 int min = 1000000; min 1000000 for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			sumW += W[i];
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			W[i] = sc.nextInt();
			sumW += W[i];
		} {
			W[i] = sc.nextInt();
			sumW += W[i];
		} W[i] = sc.nextInt() W[i] W i sc.nextInt() sc.nextInt sc sumW += W[i] sumW W[i] W i for (int i = 0; i < N - 1; i++) {
			a += W[i];
			b = sumW - a;

			if (min >= Math.abs(a-b)) {
				min = Math.abs(a-b);
			}
		} int i = 0; int i = 0; i 0 i < N - 1 i N - 1 N 1 i++ i++ i {
			a += W[i];
			b = sumW - a;

			if (min >= Math.abs(a-b)) {
				min = Math.abs(a-b);
			}
		} {
			a += W[i];
			b = sumW - a;

			if (min >= Math.abs(a-b)) {
				min = Math.abs(a-b);
			}
		} a += W[i] a W[i] W i b = sumW - a b sumW - a sumW a if (min >= Math.abs(a-b)) {
				min = Math.abs(a-b);
			} min >= Math.abs(a-b) min Math.abs(a-b) Math.abs Math a-b a b {
				min = Math.abs(a-b);
			} min = Math.abs(a-b) min Math.abs(a-b) Math.abs Math a-b a b System.out.print(min) System.out.print System.out System System.out min String arg[] arg public class Main {
	public static void main(String arg[]) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int W[] = new int[N];
		int a = 0;
		int b = 0;
		int sumW = 0;
		int min = 1000000;

		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			sumW += W[i];
		}

		for (int i = 0; i < N - 1; i++) {
			a += W[i];
			b = sumW - a;

			if (min >= Math.abs(a-b)) {
				min = Math.abs(a-b);
			}
		}

		System.out.print(min);
	}
} public class Main {
	public static void main(String arg[]) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int W[] = new int[N];
		int a = 0;
		int b = 0;
		int sumW = 0;
		int min = 1000000;

		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			sumW += W[i];
		}

		for (int i = 0; i < N - 1; i++) {
			a += W[i];
			b = sumW - a;

			if (min >= Math.abs(a-b)) {
				min = Math.abs(a-b);
			}
		}

		System.out.print(min);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String arg[]) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int W[] = new int[N];
		int a = 0;
		int b = 0;
		int sumW = 0;
		int min = 1000000;

		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			sumW += W[i];
		}

		for (int i = 0; i < N - 1; i++) {
			a += W[i];
			b = sumW - a;

			if (min >= Math.abs(a-b)) {
				min = Math.abs(a-b);
			}
		}

		System.out.print(min);
	}
}