import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws java.lang.Exception {
		Scanner scanner = new Scanner(System.in);
		int max = scanner.nextInt();
      	scanner.nextLine();
		String input = scanner.nextLine();
		String[] inputArray = input.split(" ");
		int minDiff = 10000;
		for(int i=1; i < max; i++){
			int s1 = 0;
			int s2 = 0;
			for(int j=0; j < max; j++){
				if (i > j){
					s1 += Integer.parseInt(inputArray[j]);
				}else{
					s2 += Integer.parseInt(inputArray[j]);
				}

			}
			int diff = s1 - s2;
			if(diff < 0){
				diff = diff * -1;
			}
			minDiff = Math.min(minDiff, diff);
		}

	    System.out.println(minDiff);
	    scanner.close();
	}
}

/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