import java.io.*;

public class Main {
	public static void main(String[] args) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		
		int n = 0;
		try {
			n = Integer.parseInt(br.readLine());
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		int [] w = new int[n];
		
		try {
			String str = br.readLine();
			String [] strs = str.split(" ");
			for(int i = 0; i < n; i++) {
				w[i] = Integer.parseInt(strs[i]);
			}
			br.close();
		} catch  (IOException e){
			e.printStackTrace();
		}
		
		int min = Math.abs(w[0] - Sum(1, n-1, w));
		
		for(int i = 1; i < n; i++) {
			int sum;
			if(min > (sum = Math.abs(Sum(0, i, w) - Sum(i+1, n-1, w)))) {
				min = sum;
			}
		}
		
		System.out.println(min);
	}
	
	static int Sum(int a, int n, int[] w){
		int sum = 0;
		for(int i = a; i <= n; i++) {
			sum += w[i];
		}
		return sum;
	}
} import java.io.*; io.* java public class Main {
	public static void main(String[] args) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		
		int n = 0;
		try {
			n = Integer.parseInt(br.readLine());
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		int [] w = new int[n];
		
		try {
			String str = br.readLine();
			String [] strs = str.split(" ");
			for(int i = 0; i < n; i++) {
				w[i] = Integer.parseInt(strs[i]);
			}
			br.close();
		} catch  (IOException e){
			e.printStackTrace();
		}
		
		int min = Math.abs(w[0] - Sum(1, n-1, w));
		
		for(int i = 1; i < n; i++) {
			int sum;
			if(min > (sum = Math.abs(Sum(0, i, w) - Sum(i+1, n-1, w)))) {
				min = sum;
			}
		}
		
		System.out.println(min);
	}
	
	static int Sum(int a, int n, int[] w){
		int sum = 0;
		for(int i = a; i <= n; i++) {
			sum += w[i];
		}
		return sum;
	}
} Main public static void main(String[] args) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		
		int n = 0;
		try {
			n = Integer.parseInt(br.readLine());
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		int [] w = new int[n];
		
		try {
			String str = br.readLine();
			String [] strs = str.split(" ");
			for(int i = 0; i < n; i++) {
				w[i] = Integer.parseInt(strs[i]);
			}
			br.close();
		} catch  (IOException e){
			e.printStackTrace();
		}
		
		int min = Math.abs(w[0] - Sum(1, n-1, w));
		
		for(int i = 1; i < n; i++) {
			int sum;
			if(min > (sum = Math.abs(Sum(0, i, w) - Sum(i+1, n-1, w)))) {
				min = sum;
			}
		}
		
		System.out.println(min);
	} main {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		
		int n = 0;
		try {
			n = Integer.parseInt(br.readLine());
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		int [] w = new int[n];
		
		try {
			String str = br.readLine();
			String [] strs = str.split(" ");
			for(int i = 0; i < n; i++) {
				w[i] = Integer.parseInt(strs[i]);
			}
			br.close();
		} catch  (IOException e){
			e.printStackTrace();
		}
		
		int min = Math.abs(w[0] - Sum(1, n-1, w));
		
		for(int i = 1; i < n; i++) {
			int sum;
			if(min > (sum = Math.abs(Sum(0, i, w) - Sum(i+1, n-1, w)))) {
				min = sum;
			}
		}
		
		System.out.println(min);
	} InputStreamReader isr = new InputStreamReader(System.in); isr new InputStreamReader(System.in) BufferedReader br = new BufferedReader(isr); br new BufferedReader(isr) int n = 0; n 0 try {
			n = Integer.parseInt(br.readLine());
		} catch (IOException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} IOException e {
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
			n = Integer.parseInt(br.readLine());
		} n = Integer.parseInt(br.readLine()) n Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int [] w = new int[n]; w new int[n] n try {
			String str = br.readLine();
			String [] strs = str.split(" ");
			for(int i = 0; i < n; i++) {
				w[i] = Integer.parseInt(strs[i]);
			}
			br.close();
		} catch  (IOException e){
			e.printStackTrace();
		} catch  (IOException e){
			e.printStackTrace();
		} IOException e {
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
			String str = br.readLine();
			String [] strs = str.split(" ");
			for(int i = 0; i < n; i++) {
				w[i] = Integer.parseInt(strs[i]);
			}
			br.close();
		} String str = br.readLine(); str br.readLine() br.readLine br String [] strs = str.split(" "); strs str.split(" ") str.split str " " for(int i = 0; i < n; i++) {
				w[i] = Integer.parseInt(strs[i]);
			} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
				w[i] = Integer.parseInt(strs[i]);
			} {
				w[i] = Integer.parseInt(strs[i]);
			} w[i] = Integer.parseInt(strs[i]) w[i] w i Integer.parseInt(strs[i]) Integer.parseInt Integer strs[i] strs i br.close() br.close br int min = Math.abs(w[0] - Sum(1, n-1, w)); min Math.abs(w[0] - Sum(1, n-1, w)) Math.abs Math w[0] - Sum(1, n-1, w) w[0] w 0 Sum(1, n-1, w) Sum 1 n-1 n 1 w for(int i = 1; i < n; i++) {
			int sum;
			if(min > (sum = Math.abs(Sum(0, i, w) - Sum(i+1, n-1, w)))) {
				min = sum;
			}
		} int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
			int sum;
			if(min > (sum = Math.abs(Sum(0, i, w) - Sum(i+1, n-1, w)))) {
				min = sum;
			}
		} {
			int sum;
			if(min > (sum = Math.abs(Sum(0, i, w) - Sum(i+1, n-1, w)))) {
				min = sum;
			}
		} int sum; sum if(min > (sum = Math.abs(Sum(0, i, w) - Sum(i+1, n-1, w)))) {
				min = sum;
			} min > (sum = Math.abs(Sum(0, i, w) - Sum(i+1, n-1, w))) min (sum = Math.abs(Sum(0, i, w) - Sum(i+1, n-1, w))) sum Math.abs(Sum(0, i, w) - Sum(i+1, n-1, w)) Math.abs Math Sum(0, i, w) - Sum(i+1, n-1, w) Sum(0, i, w) Sum 0 i w Sum(i+1, n-1, w) Sum i+1 i 1 n-1 n 1 w {
				min = sum;
			} min = sum min sum System.out.println(min) System.out.println System.out System System.out min String[] args args static int Sum(int a, int n, int[] w){
		int sum = 0;
		for(int i = a; i <= n; i++) {
			sum += w[i];
		}
		return sum;
	} Sum {
		int sum = 0;
		for(int i = a; i <= n; i++) {
			sum += w[i];
		}
		return sum;
	} int sum = 0; sum 0 for(int i = a; i <= n; i++) {
			sum += w[i];
		} int i = a; int i = a; i a i <= n i n i++ i++ i {
			sum += w[i];
		} {
			sum += w[i];
		} sum += w[i] sum w[i] w i return sum; sum int a a int n n int[] w w public class Main {
	public static void main(String[] args) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		
		int n = 0;
		try {
			n = Integer.parseInt(br.readLine());
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		int [] w = new int[n];
		
		try {
			String str = br.readLine();
			String [] strs = str.split(" ");
			for(int i = 0; i < n; i++) {
				w[i] = Integer.parseInt(strs[i]);
			}
			br.close();
		} catch  (IOException e){
			e.printStackTrace();
		}
		
		int min = Math.abs(w[0] - Sum(1, n-1, w));
		
		for(int i = 1; i < n; i++) {
			int sum;
			if(min > (sum = Math.abs(Sum(0, i, w) - Sum(i+1, n-1, w)))) {
				min = sum;
			}
		}
		
		System.out.println(min);
	}
	
	static int Sum(int a, int n, int[] w){
		int sum = 0;
		for(int i = a; i <= n; i++) {
			sum += w[i];
		}
		return sum;
	}
} public class Main {
	public static void main(String[] args) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		
		int n = 0;
		try {
			n = Integer.parseInt(br.readLine());
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		int [] w = new int[n];
		
		try {
			String str = br.readLine();
			String [] strs = str.split(" ");
			for(int i = 0; i < n; i++) {
				w[i] = Integer.parseInt(strs[i]);
			}
			br.close();
		} catch  (IOException e){
			e.printStackTrace();
		}
		
		int min = Math.abs(w[0] - Sum(1, n-1, w));
		
		for(int i = 1; i < n; i++) {
			int sum;
			if(min > (sum = Math.abs(Sum(0, i, w) - Sum(i+1, n-1, w)))) {
				min = sum;
			}
		}
		
		System.out.println(min);
	}
	
	static int Sum(int a, int n, int[] w){
		int sum = 0;
		for(int i = a; i <= n; i++) {
			sum += w[i];
		}
		return sum;
	}
} Main
import java.io.*;

public class Main {
	public static void main(String[] args) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		
		int n = 0;
		try {
			n = Integer.parseInt(br.readLine());
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		int [] w = new int[n];
		
		try {
			String str = br.readLine();
			String [] strs = str.split(" ");
			for(int i = 0; i < n; i++) {
				w[i] = Integer.parseInt(strs[i]);
			}
			br.close();
		} catch  (IOException e){
			e.printStackTrace();
		}
		
		int min = Math.abs(w[0] - Sum(1, n-1, w));
		
		for(int i = 1; i < n; i++) {
			int sum;
			if(min > (sum = Math.abs(Sum(0, i, w) - Sum(i+1, n-1, w)))) {
				min = sum;
			}
		}
		
		System.out.println(min);
	}
	
	static int Sum(int a, int n, int[] w){
		int sum = 0;
		for(int i = a; i <= n; i++) {
			sum += w[i];
		}
		return sum;
	}
}