import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		int N = sc.nextInt();
		int[] W = new int[N];
		int sum = 0;
		for(int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			sum += W[i];
		}
		int min = Integer.MAX_VALUE;
		for(int i = 1; i < N; i++) {
			int S1 = 0;
			for(int j = 0; j < i; j++) {
				S1 += W[j];
			}
			min = Math.min(min, Math.abs(S1 - (sum - S1)));
		}
		System.out.println(min);
	}
} import java.util.Scanner; Scanner java.util class Main{
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		int N = sc.nextInt();
		int[] W = new int[N];
		int sum = 0;
		for(int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			sum += W[i];
		}
		int min = Integer.MAX_VALUE;
		for(int i = 1; i < N; i++) {
			int S1 = 0;
			for(int j = 0; j < i; j++) {
				S1 += W[j];
			}
			min = Math.min(min, Math.abs(S1 - (sum - S1)));
		}
		System.out.println(min);
	}
} Main public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		int N = sc.nextInt();
		int[] W = new int[N];
		int sum = 0;
		for(int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			sum += W[i];
		}
		int min = Integer.MAX_VALUE;
		for(int i = 1; i < N; i++) {
			int S1 = 0;
			for(int j = 0; j < i; j++) {
				S1 += W[j];
			}
			min = Math.min(min, Math.abs(S1 - (sum - S1)));
		}
		System.out.println(min);
	} main {
		Scanner sc=new Scanner(System.in);
		int N = sc.nextInt();
		int[] W = new int[N];
		int sum = 0;
		for(int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			sum += W[i];
		}
		int min = Integer.MAX_VALUE;
		for(int i = 1; i < N; i++) {
			int S1 = 0;
			for(int j = 0; j < i; j++) {
				S1 += W[j];
			}
			min = Math.min(min, Math.abs(S1 - (sum - S1)));
		}
		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 int sum = 0; sum 0 for(int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			sum += W[i];
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			W[i] = sc.nextInt();
			sum += W[i];
		} {
			W[i] = sc.nextInt();
			sum += W[i];
		} W[i] = sc.nextInt() W[i] W i sc.nextInt() sc.nextInt sc sum += W[i] sum W[i] W i int min = Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE for(int i = 1; i < N; i++) {
			int S1 = 0;
			for(int j = 0; j < i; j++) {
				S1 += W[j];
			}
			min = Math.min(min, Math.abs(S1 - (sum - S1)));
		} int i = 1; int i = 1; i 1 i < N i N i++ i++ i {
			int S1 = 0;
			for(int j = 0; j < i; j++) {
				S1 += W[j];
			}
			min = Math.min(min, Math.abs(S1 - (sum - S1)));
		} {
			int S1 = 0;
			for(int j = 0; j < i; j++) {
				S1 += W[j];
			}
			min = Math.min(min, Math.abs(S1 - (sum - S1)));
		} int S1 = 0; S1 0 for(int j = 0; j < i; j++) {
				S1 += W[j];
			} int j = 0; int j = 0; j 0 j < i j i j++ j++ j {
				S1 += W[j];
			} {
				S1 += W[j];
			} S1 += W[j] S1 W[j] W j min = Math.min(min, Math.abs(S1 - (sum - S1))) min Math.min(min, Math.abs(S1 - (sum - S1))) Math.min Math min Math.abs(S1 - (sum - S1)) Math.abs Math S1 - (sum - S1) S1 (sum - S1) sum S1 System.out.println(min) System.out.println System.out System System.out min String args[] args
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		int N = sc.nextInt();
		int[] W = new int[N];
		int sum = 0;
		for(int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			sum += W[i];
		}
		int min = Integer.MAX_VALUE;
		for(int i = 1; i < N; i++) {
			int S1 = 0;
			for(int j = 0; j < i; j++) {
				S1 += W[j];
			}
			min = Math.min(min, Math.abs(S1 - (sum - S1)));
		}
		System.out.println(min);
	}
}