import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int[] array = new int[a];
		int w1 = 0;
		int w2 = 0;
		int min = 0;
		int flag = 0;
		for(int i = 0; i < array.length; i++) {
			array[i] = sc.nextInt();
		}
		for(int i = 1; i < array.length; i++) {
			for(int j = 0; j <= i; j++) {
				w1 += array[j];
			}
			for(int j = array.length - 1; j > i; j--) {
				w2 += array[j];
			}
			if(flag == 0) {
				min = Math.abs(w1 - w2);
				flag = 1;
			}else if(Math.abs(w1 - w2) < min) {
				min = Math.abs(w1 - w2);
			}
			w1 = 0;
			w2 = 0;
		}
		System.out.println(min);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int[] array = new int[a];
		int w1 = 0;
		int w2 = 0;
		int min = 0;
		int flag = 0;
		for(int i = 0; i < array.length; i++) {
			array[i] = sc.nextInt();
		}
		for(int i = 1; i < array.length; i++) {
			for(int j = 0; j <= i; j++) {
				w1 += array[j];
			}
			for(int j = array.length - 1; j > i; j--) {
				w2 += array[j];
			}
			if(flag == 0) {
				min = Math.abs(w1 - w2);
				flag = 1;
			}else if(Math.abs(w1 - w2) < min) {
				min = Math.abs(w1 - w2);
			}
			w1 = 0;
			w2 = 0;
		}
		System.out.println(min);
	}
} Main public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int[] array = new int[a];
		int w1 = 0;
		int w2 = 0;
		int min = 0;
		int flag = 0;
		for(int i = 0; i < array.length; i++) {
			array[i] = sc.nextInt();
		}
		for(int i = 1; i < array.length; i++) {
			for(int j = 0; j <= i; j++) {
				w1 += array[j];
			}
			for(int j = array.length - 1; j > i; j--) {
				w2 += array[j];
			}
			if(flag == 0) {
				min = Math.abs(w1 - w2);
				flag = 1;
			}else if(Math.abs(w1 - w2) < min) {
				min = Math.abs(w1 - w2);
			}
			w1 = 0;
			w2 = 0;
		}
		System.out.println(min);
	} main {
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int[] array = new int[a];
		int w1 = 0;
		int w2 = 0;
		int min = 0;
		int flag = 0;
		for(int i = 0; i < array.length; i++) {
			array[i] = sc.nextInt();
		}
		for(int i = 1; i < array.length; i++) {
			for(int j = 0; j <= i; j++) {
				w1 += array[j];
			}
			for(int j = array.length - 1; j > i; j--) {
				w2 += array[j];
			}
			if(flag == 0) {
				min = Math.abs(w1 - w2);
				flag = 1;
			}else if(Math.abs(w1 - w2) < min) {
				min = Math.abs(w1 - w2);
			}
			w1 = 0;
			w2 = 0;
		}
		System.out.println(min);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int[] array = new int[a]; array new int[a] a int w1 = 0; w1 0 int w2 = 0; w2 0 int min = 0; min 0 int flag = 0; flag 0 for(int i = 0; i < array.length; i++) {
			array[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < array.length i array.length array array.length i++ i++ i {
			array[i] = sc.nextInt();
		} {
			array[i] = sc.nextInt();
		} array[i] = sc.nextInt() array[i] array i sc.nextInt() sc.nextInt sc for(int i = 1; i < array.length; i++) {
			for(int j = 0; j <= i; j++) {
				w1 += array[j];
			}
			for(int j = array.length - 1; j > i; j--) {
				w2 += array[j];
			}
			if(flag == 0) {
				min = Math.abs(w1 - w2);
				flag = 1;
			}else if(Math.abs(w1 - w2) < min) {
				min = Math.abs(w1 - w2);
			}
			w1 = 0;
			w2 = 0;
		} int i = 1; int i = 1; i 1 i < array.length i array.length array array.length i++ i++ i {
			for(int j = 0; j <= i; j++) {
				w1 += array[j];
			}
			for(int j = array.length - 1; j > i; j--) {
				w2 += array[j];
			}
			if(flag == 0) {
				min = Math.abs(w1 - w2);
				flag = 1;
			}else if(Math.abs(w1 - w2) < min) {
				min = Math.abs(w1 - w2);
			}
			w1 = 0;
			w2 = 0;
		} {
			for(int j = 0; j <= i; j++) {
				w1 += array[j];
			}
			for(int j = array.length - 1; j > i; j--) {
				w2 += array[j];
			}
			if(flag == 0) {
				min = Math.abs(w1 - w2);
				flag = 1;
			}else if(Math.abs(w1 - w2) < min) {
				min = Math.abs(w1 - w2);
			}
			w1 = 0;
			w2 = 0;
		} for(int j = 0; j <= i; j++) {
				w1 += array[j];
			} int j = 0; int j = 0; j 0 j <= i j i j++ j++ j {
				w1 += array[j];
			} {
				w1 += array[j];
			} w1 += array[j] w1 array[j] array j for(int j = array.length - 1; j > i; j--) {
				w2 += array[j];
			} int j = array.length - 1; int j = array.length - 1; j array.length - 1 array.length array array.length 1 j > i j i j-- j-- j {
				w2 += array[j];
			} {
				w2 += array[j];
			} w2 += array[j] w2 array[j] array j if(flag == 0) {
				min = Math.abs(w1 - w2);
				flag = 1;
			}else if(Math.abs(w1 - w2) < min) {
				min = Math.abs(w1 - w2);
			} flag == 0 flag 0 {
				min = Math.abs(w1 - w2);
				flag = 1;
			} min = Math.abs(w1 - w2) min Math.abs(w1 - w2) Math.abs Math w1 - w2 w1 w2 flag = 1 flag 1 if(Math.abs(w1 - w2) < min) {
				min = Math.abs(w1 - w2);
			} Math.abs(w1 - w2) < min Math.abs(w1 - w2) Math.abs Math w1 - w2 w1 w2 min {
				min = Math.abs(w1 - w2);
			} min = Math.abs(w1 - w2) min Math.abs(w1 - w2) Math.abs Math w1 - w2 w1 w2 w1 = 0 w1 0 w2 = 0 w2 0 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) {
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int[] array = new int[a];
		int w1 = 0;
		int w2 = 0;
		int min = 0;
		int flag = 0;
		for(int i = 0; i < array.length; i++) {
			array[i] = sc.nextInt();
		}
		for(int i = 1; i < array.length; i++) {
			for(int j = 0; j <= i; j++) {
				w1 += array[j];
			}
			for(int j = array.length - 1; j > i; j--) {
				w2 += array[j];
			}
			if(flag == 0) {
				min = Math.abs(w1 - w2);
				flag = 1;
			}else if(Math.abs(w1 - w2) < min) {
				min = Math.abs(w1 - w2);
			}
			w1 = 0;
			w2 = 0;
		}
		System.out.println(min);
	}
} public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int[] array = new int[a];
		int w1 = 0;
		int w2 = 0;
		int min = 0;
		int flag = 0;
		for(int i = 0; i < array.length; i++) {
			array[i] = sc.nextInt();
		}
		for(int i = 1; i < array.length; i++) {
			for(int j = 0; j <= i; j++) {
				w1 += array[j];
			}
			for(int j = array.length - 1; j > i; j--) {
				w2 += array[j];
			}
			if(flag == 0) {
				min = Math.abs(w1 - w2);
				flag = 1;
			}else if(Math.abs(w1 - w2) < min) {
				min = Math.abs(w1 - w2);
			}
			w1 = 0;
			w2 = 0;
		}
		System.out.println(min);
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int[] array = new int[a];
		int w1 = 0;
		int w2 = 0;
		int min = 0;
		int flag = 0;
		for(int i = 0; i < array.length; i++) {
			array[i] = sc.nextInt();
		}
		for(int i = 1; i < array.length; i++) {
			for(int j = 0; j <= i; j++) {
				w1 += array[j];
			}
			for(int j = array.length - 1; j > i; j--) {
				w2 += array[j];
			}
			if(flag == 0) {
				min = Math.abs(w1 - w2);
				flag = 1;
			}else if(Math.abs(w1 - w2) < min) {
				min = Math.abs(w1 - w2);
			}
			w1 = 0;
			w2 = 0;
		}
		System.out.println(min);
	}
}