import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] W = new int[N];
		W[0] = sc.nextInt();
		for(int i=1;i<N;i++) {
			W[i]=W[i-1]+sc.nextInt();
		}
		int min = 100000;
		for(int i=1;i<N-1;i++) {
			int diff = Math.abs((W[N-1]-W[i])-W[i]);
			if(diff<min) {
				min = diff;
			}
		}
		System.out.println(min);
	}
} import java.io.FileNotFoundException; FileNotFoundException java.io import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] W = new int[N];
		W[0] = sc.nextInt();
		for(int i=1;i<N;i++) {
			W[i]=W[i-1]+sc.nextInt();
		}
		int min = 100000;
		for(int i=1;i<N-1;i++) {
			int diff = Math.abs((W[N-1]-W[i])-W[i]);
			if(diff<min) {
				min = diff;
			}
		}
		System.out.println(min);
	}
} Main public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] W = new int[N];
		W[0] = sc.nextInt();
		for(int i=1;i<N;i++) {
			W[i]=W[i-1]+sc.nextInt();
		}
		int min = 100000;
		for(int i=1;i<N-1;i++) {
			int diff = Math.abs((W[N-1]-W[i])-W[i]);
			if(diff<min) {
				min = diff;
			}
		}
		System.out.println(min);
	} main {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] W = new int[N];
		W[0] = sc.nextInt();
		for(int i=1;i<N;i++) {
			W[i]=W[i-1]+sc.nextInt();
		}
		int min = 100000;
		for(int i=1;i<N-1;i++) {
			int diff = Math.abs((W[N-1]-W[i])-W[i]);
			if(diff<min) {
				min = diff;
			}
		}
		System.out.println(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 W[0] = sc.nextInt() W[0] W 0 sc.nextInt() sc.nextInt sc for(int i=1;i<N;i++) {
			W[i]=W[i-1]+sc.nextInt();
		} int i=1; int i=1; i 1 i<N i N i++ i++ i {
			W[i]=W[i-1]+sc.nextInt();
		} {
			W[i]=W[i-1]+sc.nextInt();
		} W[i]=W[i-1]+sc.nextInt() W[i] W i W[i-1]+sc.nextInt() W[i-1] W i-1 i 1 sc.nextInt() sc.nextInt sc int min = 100000; min 100000 for(int i=1;i<N-1;i++) {
			int diff = Math.abs((W[N-1]-W[i])-W[i]);
			if(diff<min) {
				min = diff;
			}
		} int i=1; int i=1; i 1 i<N-1 i N-1 N 1 i++ i++ i {
			int diff = Math.abs((W[N-1]-W[i])-W[i]);
			if(diff<min) {
				min = diff;
			}
		} {
			int diff = Math.abs((W[N-1]-W[i])-W[i]);
			if(diff<min) {
				min = diff;
			}
		} int diff = Math.abs((W[N-1]-W[i])-W[i]); diff Math.abs((W[N-1]-W[i])-W[i]) Math.abs Math (W[N-1]-W[i])-W[i] (W[N-1]-W[i]) W[N-1] W N-1 N 1 W[i] W i W[i] W i if(diff<min) {
				min = diff;
			} diff<min diff min {
				min = diff;
			} min = diff min diff 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) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] W = new int[N];
		W[0] = sc.nextInt();
		for(int i=1;i<N;i++) {
			W[i]=W[i-1]+sc.nextInt();
		}
		int min = 100000;
		for(int i=1;i<N-1;i++) {
			int diff = Math.abs((W[N-1]-W[i])-W[i]);
			if(diff<min) {
				min = diff;
			}
		}
		System.out.println(min);
	}
} public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] W = new int[N];
		W[0] = sc.nextInt();
		for(int i=1;i<N;i++) {
			W[i]=W[i-1]+sc.nextInt();
		}
		int min = 100000;
		for(int i=1;i<N-1;i++) {
			int diff = Math.abs((W[N-1]-W[i])-W[i]);
			if(diff<min) {
				min = diff;
			}
		}
		System.out.println(min);
	}
} Main
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] W = new int[N];
		W[0] = sc.nextInt();
		for(int i=1;i<N;i++) {
			W[i]=W[i-1]+sc.nextInt();
		}
		int min = 100000;
		for(int i=1;i<N-1;i++) {
			int diff = Math.abs((W[N-1]-W[i])-W[i]);
			if(diff<min) {
				min = diff;
			}
		}
		System.out.println(min);
	}
}