import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] w = new int[N];
		int sum = 0;
		for (int i = 0; i < N; i++) {
			w[i] = Integer.parseInt(sc.next());
			sum += w[i];
		}
		sc.close();

		int s1 = w[0];
		int s2 = sum - w[0];
		int ans = Math.abs(s2 - s1);
		for (int i = 1; i < N - 1; i++) {
			s1 += w[i];
			s2 -= w[i];
			ans = Math.min(ans, Math.abs(s2 - s1));
		}
		System.out.println(ans);

	}

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

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] w = new int[N];
		int sum = 0;
		for (int i = 0; i < N; i++) {
			w[i] = Integer.parseInt(sc.next());
			sum += w[i];
		}
		sc.close();

		int s1 = w[0];
		int s2 = sum - w[0];
		int ans = Math.abs(s2 - s1);
		for (int i = 1; i < N - 1; i++) {
			s1 += w[i];
			s2 -= w[i];
			ans = Math.min(ans, Math.abs(s2 - s1));
		}
		System.out.println(ans);

	}

} Main public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] w = new int[N];
		int sum = 0;
		for (int i = 0; i < N; i++) {
			w[i] = Integer.parseInt(sc.next());
			sum += w[i];
		}
		sc.close();

		int s1 = w[0];
		int s2 = sum - w[0];
		int ans = Math.abs(s2 - s1);
		for (int i = 1; i < N - 1; i++) {
			s1 += w[i];
			s2 -= w[i];
			ans = Math.min(ans, Math.abs(s2 - s1));
		}
		System.out.println(ans);

	} main {

		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] w = new int[N];
		int sum = 0;
		for (int i = 0; i < N; i++) {
			w[i] = Integer.parseInt(sc.next());
			sum += w[i];
		}
		sc.close();

		int s1 = w[0];
		int s2 = sum - w[0];
		int ans = Math.abs(s2 - s1);
		for (int i = 1; i < N - 1; i++) {
			s1 += w[i];
			s2 -= w[i];
			ans = Math.min(ans, Math.abs(s2 - s1));
		}
		System.out.println(ans);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = Integer.parseInt(sc.next()); N Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int[] w = new int[N]; w new int[N] N int sum = 0; sum 0 for (int i = 0; i < N; i++) {
			w[i] = Integer.parseInt(sc.next());
			sum += w[i];
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			w[i] = Integer.parseInt(sc.next());
			sum += w[i];
		} {
			w[i] = Integer.parseInt(sc.next());
			sum += w[i];
		} w[i] = Integer.parseInt(sc.next()) w[i] w i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc sum += w[i] sum w[i] w i sc.close() sc.close sc int s1 = w[0]; s1 w[0] w 0 int s2 = sum - w[0]; s2 sum - w[0] sum w[0] w 0 int ans = Math.abs(s2 - s1); ans Math.abs(s2 - s1) Math.abs Math s2 - s1 s2 s1 for (int i = 1; i < N - 1; i++) {
			s1 += w[i];
			s2 -= w[i];
			ans = Math.min(ans, Math.abs(s2 - s1));
		} int i = 1; int i = 1; i 1 i < N - 1 i N - 1 N 1 i++ i++ i {
			s1 += w[i];
			s2 -= w[i];
			ans = Math.min(ans, Math.abs(s2 - s1));
		} {
			s1 += w[i];
			s2 -= w[i];
			ans = Math.min(ans, Math.abs(s2 - s1));
		} s1 += w[i] s1 w[i] w i s2 -= w[i] s2 w[i] w i ans = Math.min(ans, Math.abs(s2 - s1)) ans Math.min(ans, Math.abs(s2 - s1)) Math.min Math ans Math.abs(s2 - s1) Math.abs Math s2 - s1 s2 s1 System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] w = new int[N];
		int sum = 0;
		for (int i = 0; i < N; i++) {
			w[i] = Integer.parseInt(sc.next());
			sum += w[i];
		}
		sc.close();

		int s1 = w[0];
		int s2 = sum - w[0];
		int ans = Math.abs(s2 - s1);
		for (int i = 1; i < N - 1; i++) {
			s1 += w[i];
			s2 -= w[i];
			ans = Math.min(ans, Math.abs(s2 - s1));
		}
		System.out.println(ans);

	}

} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] w = new int[N];
		int sum = 0;
		for (int i = 0; i < N; i++) {
			w[i] = Integer.parseInt(sc.next());
			sum += w[i];
		}
		sc.close();

		int s1 = w[0];
		int s2 = sum - w[0];
		int ans = Math.abs(s2 - s1);
		for (int i = 1; i < N - 1; i++) {
			s1 += w[i];
			s2 -= w[i];
			ans = Math.min(ans, Math.abs(s2 - s1));
		}
		System.out.println(ans);

	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] w = new int[N];
		int sum = 0;
		for (int i = 0; i < N; i++) {
			w[i] = Integer.parseInt(sc.next());
			sum += w[i];
		}
		sc.close();

		int s1 = w[0];
		int s2 = sum - w[0];
		int ans = Math.abs(s2 - s1);
		for (int i = 1; i < N - 1; i++) {
			s1 += w[i];
			s2 -= w[i];
			ans = Math.min(ans, Math.abs(s2 - s1));
		}
		System.out.println(ans);

	}

}
