import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < N; i++) {
			list.add(scan.nextInt());
		}
		int min = 100000;
		for (int i = 0; i < N; i++) {
			int ant = 0;
			int post = 0;
			for (int j = 0; j <= i; j++) {
				ant += list.get(j);
			}
			for (int j = i + 1; j < N; j++) {
				post += list.get(j);
			}
			if (min > Math.abs(ant - post)) {
				min = Math.abs(ant - post);
			}
		}
		System.out.println(min);
	}

} import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < N; i++) {
			list.add(scan.nextInt());
		}
		int min = 100000;
		for (int i = 0; i < N; i++) {
			int ant = 0;
			int post = 0;
			for (int j = 0; j <= i; j++) {
				ant += list.get(j);
			}
			for (int j = i + 1; j < N; j++) {
				post += list.get(j);
			}
			if (min > Math.abs(ant - post)) {
				min = Math.abs(ant - post);
			}
		}
		System.out.println(min);
	}

} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < N; i++) {
			list.add(scan.nextInt());
		}
		int min = 100000;
		for (int i = 0; i < N; i++) {
			int ant = 0;
			int post = 0;
			for (int j = 0; j <= i; j++) {
				ant += list.get(j);
			}
			for (int j = i + 1; j < N; j++) {
				post += list.get(j);
			}
			if (min > Math.abs(ant - post)) {
				min = Math.abs(ant - post);
			}
		}
		System.out.println(min);
	} main {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < N; i++) {
			list.add(scan.nextInt());
		}
		int min = 100000;
		for (int i = 0; i < N; i++) {
			int ant = 0;
			int post = 0;
			for (int j = 0; j <= i; j++) {
				ant += list.get(j);
			}
			for (int j = i + 1; j < N; j++) {
				post += list.get(j);
			}
			if (min > Math.abs(ant - post)) {
				min = Math.abs(ant - post);
			}
		}
		System.out.println(min);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan List<Integer> list = new ArrayList<Integer>(); list new ArrayList<Integer>() for (int i = 0; i < N; i++) {
			list.add(scan.nextInt());
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			list.add(scan.nextInt());
		} {
			list.add(scan.nextInt());
		} list.add(scan.nextInt()) list.add list scan.nextInt() scan.nextInt scan int min = 100000; min 100000 for (int i = 0; i < N; i++) {
			int ant = 0;
			int post = 0;
			for (int j = 0; j <= i; j++) {
				ant += list.get(j);
			}
			for (int j = i + 1; j < N; j++) {
				post += list.get(j);
			}
			if (min > Math.abs(ant - post)) {
				min = Math.abs(ant - post);
			}
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			int ant = 0;
			int post = 0;
			for (int j = 0; j <= i; j++) {
				ant += list.get(j);
			}
			for (int j = i + 1; j < N; j++) {
				post += list.get(j);
			}
			if (min > Math.abs(ant - post)) {
				min = Math.abs(ant - post);
			}
		} {
			int ant = 0;
			int post = 0;
			for (int j = 0; j <= i; j++) {
				ant += list.get(j);
			}
			for (int j = i + 1; j < N; j++) {
				post += list.get(j);
			}
			if (min > Math.abs(ant - post)) {
				min = Math.abs(ant - post);
			}
		} int ant = 0; ant 0 int post = 0; post 0 for (int j = 0; j <= i; j++) {
				ant += list.get(j);
			} int j = 0; int j = 0; j 0 j <= i j i j++ j++ j {
				ant += list.get(j);
			} {
				ant += list.get(j);
			} ant += list.get(j) ant list.get(j) list.get list j for (int j = i + 1; j < N; j++) {
				post += list.get(j);
			} int j = i + 1; int j = i + 1; j i + 1 i 1 j < N j N j++ j++ j {
				post += list.get(j);
			} {
				post += list.get(j);
			} post += list.get(j) post list.get(j) list.get list j if (min > Math.abs(ant - post)) {
				min = Math.abs(ant - post);
			} min > Math.abs(ant - post) min Math.abs(ant - post) Math.abs Math ant - post ant post {
				min = Math.abs(ant - post);
			} min = Math.abs(ant - post) min Math.abs(ant - post) Math.abs Math ant - post ant post System.out.println(min) System.out.println System.out System System.out min String[] args args public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < N; i++) {
			list.add(scan.nextInt());
		}
		int min = 100000;
		for (int i = 0; i < N; i++) {
			int ant = 0;
			int post = 0;
			for (int j = 0; j <= i; j++) {
				ant += list.get(j);
			}
			for (int j = i + 1; j < N; j++) {
				post += list.get(j);
			}
			if (min > Math.abs(ant - post)) {
				min = Math.abs(ant - post);
			}
		}
		System.out.println(min);
	}

} public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < N; i++) {
			list.add(scan.nextInt());
		}
		int min = 100000;
		for (int i = 0; i < N; i++) {
			int ant = 0;
			int post = 0;
			for (int j = 0; j <= i; j++) {
				ant += list.get(j);
			}
			for (int j = i + 1; j < N; j++) {
				post += list.get(j);
			}
			if (min > Math.abs(ant - post)) {
				min = Math.abs(ant - post);
			}
		}
		System.out.println(min);
	}

} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < N; i++) {
			list.add(scan.nextInt());
		}
		int min = 100000;
		for (int i = 0; i < N; i++) {
			int ant = 0;
			int post = 0;
			for (int j = 0; j <= i; j++) {
				ant += list.get(j);
			}
			for (int j = i + 1; j < N; j++) {
				post += list.get(j);
			}
			if (min > Math.abs(ant - post)) {
				min = Math.abs(ant - post);
			}
		}
		System.out.println(min);
	}

}
