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();
	}
} import java.util.Scanner; Scanner java.util 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();
	}
} 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();
	} main {
		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();
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int max = scanner.nextInt(); max scanner.nextInt() scanner.nextInt scanner scanner.nextLine() scanner.nextLine scanner String input = scanner.nextLine(); input scanner.nextLine() scanner.nextLine scanner String[] inputArray = input.split(" "); inputArray input.split(" ") input.split input " " int minDiff = 10000; 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);
		} int i=1; int i=1; i 1 i < max i max i++ i++ 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);
		} {
			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);
		} int s1 = 0; s1 0 int s2 = 0; s2 0 for(int j=0; j < max; j++){
				if (i > j){
					s1 += Integer.parseInt(inputArray[j]);
				}else{
					s2 += Integer.parseInt(inputArray[j]);
				}

			} int j=0; int j=0; j 0 j < max j max j++ j++ j {
				if (i > j){
					s1 += Integer.parseInt(inputArray[j]);
				}else{
					s2 += Integer.parseInt(inputArray[j]);
				}

			} {
				if (i > j){
					s1 += Integer.parseInt(inputArray[j]);
				}else{
					s2 += Integer.parseInt(inputArray[j]);
				}

			} if (i > j){
					s1 += Integer.parseInt(inputArray[j]);
				}else{
					s2 += Integer.parseInt(inputArray[j]);
				} i > j i j {
					s1 += Integer.parseInt(inputArray[j]);
				} s1 += Integer.parseInt(inputArray[j]) s1 Integer.parseInt(inputArray[j]) Integer.parseInt Integer inputArray[j] inputArray j {
					s2 += Integer.parseInt(inputArray[j]);
				} s2 += Integer.parseInt(inputArray[j]) s2 Integer.parseInt(inputArray[j]) Integer.parseInt Integer inputArray[j] inputArray j int diff = s1 - s2; diff s1 - s2 s1 s2 if(diff < 0){
				diff = diff * -1;
			} diff < 0 diff 0 {
				diff = diff * -1;
			} diff = diff * -1 diff diff * -1 diff -1 1 minDiff = Math.min(minDiff, diff) minDiff Math.min(minDiff, diff) Math.min Math minDiff diff System.out.println(minDiff) System.out.println System.out System System.out minDiff scanner.close() scanner.close scanner String[] args args 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();
	}
} 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();
	}
} Main
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();
	}
}
