import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] W = new int[N];
		for(int i=0; i<N; i++) {
			W[i] = sc.nextInt();
		}
		
		int min = 20000;
		for(int i=0; i<N; i++) {
			int t =Math.abs(calcsum1(W,i) - calcsum2(W,i));
			if(t<min) {min = t;}
		}
		System.out.println(min);
		
		sc.close();
		
	}
	
	static int calcsum1(int[] W,int t) {
		int sum = 0;
		for(int i=0;i<=t; i++) {
			sum += W[i];
		}
		return sum;
	}
	
	static int calcsum2(int[] W,int t) {
		int sum = 0;
		for(int i=t+1;i<=W.length-1; i++) {
			sum += W[i];
		}
		return sum;
	}
	
	

} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] W = new int[N];
		for(int i=0; i<N; i++) {
			W[i] = sc.nextInt();
		}
		
		int min = 20000;
		for(int i=0; i<N; i++) {
			int t =Math.abs(calcsum1(W,i) - calcsum2(W,i));
			if(t<min) {min = t;}
		}
		System.out.println(min);
		
		sc.close();
		
	}
	
	static int calcsum1(int[] W,int t) {
		int sum = 0;
		for(int i=0;i<=t; i++) {
			sum += W[i];
		}
		return sum;
	}
	
	static int calcsum2(int[] W,int t) {
		int sum = 0;
		for(int i=t+1;i<=W.length-1; i++) {
			sum += W[i];
		}
		return sum;
	}
	
	

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] W = new int[N];
		for(int i=0; i<N; i++) {
			W[i] = sc.nextInt();
		}
		
		int min = 20000;
		for(int i=0; i<N; i++) {
			int t =Math.abs(calcsum1(W,i) - calcsum2(W,i));
			if(t<min) {min = t;}
		}
		System.out.println(min);
		
		sc.close();
		
	} main {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] W = new int[N];
		for(int i=0; i<N; i++) {
			W[i] = sc.nextInt();
		}
		
		int min = 20000;
		for(int i=0; i<N; i++) {
			int t =Math.abs(calcsum1(W,i) - calcsum2(W,i));
			if(t<min) {min = t;}
		}
		System.out.println(min);
		
		sc.close();
		
	} 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 for(int i=0; i<N; i++) {
			W[i] = sc.nextInt();
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			W[i] = sc.nextInt();
		} {
			W[i] = sc.nextInt();
		} W[i] = sc.nextInt() W[i] W i sc.nextInt() sc.nextInt sc int min = 20000; min 20000 for(int i=0; i<N; i++) {
			int t =Math.abs(calcsum1(W,i) - calcsum2(W,i));
			if(t<min) {min = t;}
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			int t =Math.abs(calcsum1(W,i) - calcsum2(W,i));
			if(t<min) {min = t;}
		} {
			int t =Math.abs(calcsum1(W,i) - calcsum2(W,i));
			if(t<min) {min = t;}
		} int t =Math.abs(calcsum1(W,i) - calcsum2(W,i)); t Math.abs(calcsum1(W,i) - calcsum2(W,i)) Math.abs Math calcsum1(W,i) - calcsum2(W,i) calcsum1(W,i) calcsum1 W i calcsum2(W,i) calcsum2 W i if(t<min) {min = t;} t<min t min {min = t;} min = t min t System.out.println(min) System.out.println System.out System System.out min sc.close() sc.close sc String[] args args static int calcsum1(int[] W,int t) {
		int sum = 0;
		for(int i=0;i<=t; i++) {
			sum += W[i];
		}
		return sum;
	} calcsum1 {
		int sum = 0;
		for(int i=0;i<=t; i++) {
			sum += W[i];
		}
		return sum;
	} int sum = 0; sum 0 for(int i=0;i<=t; i++) {
			sum += W[i];
		} int i=0; int i=0; i 0 i<=t i t i++ i++ i {
			sum += W[i];
		} {
			sum += W[i];
		} sum += W[i] sum W[i] W i return sum; sum int[] W W int t t static int calcsum2(int[] W,int t) {
		int sum = 0;
		for(int i=t+1;i<=W.length-1; i++) {
			sum += W[i];
		}
		return sum;
	} calcsum2 {
		int sum = 0;
		for(int i=t+1;i<=W.length-1; i++) {
			sum += W[i];
		}
		return sum;
	} int sum = 0; sum 0 for(int i=t+1;i<=W.length-1; i++) {
			sum += W[i];
		} int i=t+1; int i=t+1; i t+1 t 1 i<=W.length-1 i W.length-1 W.length W W.length 1 i++ i++ i {
			sum += W[i];
		} {
			sum += W[i];
		} sum += W[i] sum W[i] W i return sum; sum int[] W W int t t public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] W = new int[N];
		for(int i=0; i<N; i++) {
			W[i] = sc.nextInt();
		}
		
		int min = 20000;
		for(int i=0; i<N; i++) {
			int t =Math.abs(calcsum1(W,i) - calcsum2(W,i));
			if(t<min) {min = t;}
		}
		System.out.println(min);
		
		sc.close();
		
	}
	
	static int calcsum1(int[] W,int t) {
		int sum = 0;
		for(int i=0;i<=t; i++) {
			sum += W[i];
		}
		return sum;
	}
	
	static int calcsum2(int[] W,int t) {
		int sum = 0;
		for(int i=t+1;i<=W.length-1; i++) {
			sum += W[i];
		}
		return sum;
	}
	
	

} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] W = new int[N];
		for(int i=0; i<N; i++) {
			W[i] = sc.nextInt();
		}
		
		int min = 20000;
		for(int i=0; i<N; i++) {
			int t =Math.abs(calcsum1(W,i) - calcsum2(W,i));
			if(t<min) {min = t;}
		}
		System.out.println(min);
		
		sc.close();
		
	}
	
	static int calcsum1(int[] W,int t) {
		int sum = 0;
		for(int i=0;i<=t; i++) {
			sum += W[i];
		}
		return sum;
	}
	
	static int calcsum2(int[] W,int t) {
		int sum = 0;
		for(int i=t+1;i<=W.length-1; i++) {
			sum += W[i];
		}
		return sum;
	}
	
	

} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] W = new int[N];
		for(int i=0; i<N; i++) {
			W[i] = sc.nextInt();
		}
		
		int min = 20000;
		for(int i=0; i<N; i++) {
			int t =Math.abs(calcsum1(W,i) - calcsum2(W,i));
			if(t<min) {min = t;}
		}
		System.out.println(min);
		
		sc.close();
		
	}
	
	static int calcsum1(int[] W,int t) {
		int sum = 0;
		for(int i=0;i<=t; i++) {
			sum += W[i];
		}
		return sum;
	}
	
	static int calcsum2(int[] W,int t) {
		int sum = 0;
		for(int i=t+1;i<=W.length-1; i++) {
			sum += W[i];
		}
		return sum;
	}
	
	

}