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;
	}
}
/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz