import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] array = new int[N];
		int min = 0;
		for (int i = 0; i < N; i++) {
			array[i] = sc.nextInt();
			min += array[i];
		}

		int T = 0;
		int t = 0;
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < i; j++) {
				T += array[j];
			}
			for (int k = i; k < N; k++) {
				t += array[k];
			}
			int abs = Math.abs(T - t);
			if (abs < min) {
				min = abs;
			}
			t=0;
			T=0;
		}
		System.out.println(min);
	}

} 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[] array = new int[N];
		int min = 0;
		for (int i = 0; i < N; i++) {
			array[i] = sc.nextInt();
			min += array[i];
		}

		int T = 0;
		int t = 0;
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < i; j++) {
				T += array[j];
			}
			for (int k = i; k < N; k++) {
				t += array[k];
			}
			int abs = Math.abs(T - t);
			if (abs < min) {
				min = abs;
			}
			t=0;
			T=0;
		}
		System.out.println(min);
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] array = new int[N];
		int min = 0;
		for (int i = 0; i < N; i++) {
			array[i] = sc.nextInt();
			min += array[i];
		}

		int T = 0;
		int t = 0;
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < i; j++) {
				T += array[j];
			}
			for (int k = i; k < N; k++) {
				t += array[k];
			}
			int abs = Math.abs(T - t);
			if (abs < min) {
				min = abs;
			}
			t=0;
			T=0;
		}
		System.out.println(min);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] array = new int[N];
		int min = 0;
		for (int i = 0; i < N; i++) {
			array[i] = sc.nextInt();
			min += array[i];
		}

		int T = 0;
		int t = 0;
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < i; j++) {
				T += array[j];
			}
			for (int k = i; k < N; k++) {
				t += array[k];
			}
			int abs = Math.abs(T - t);
			if (abs < min) {
				min = abs;
			}
			t=0;
			T=0;
		}
		System.out.println(min);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] array = new int[N]; array new int[N] N int min = 0; min 0 for (int i = 0; i < N; i++) {
			array[i] = sc.nextInt();
			min += array[i];
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			array[i] = sc.nextInt();
			min += array[i];
		} {
			array[i] = sc.nextInt();
			min += array[i];
		} array[i] = sc.nextInt() array[i] array i sc.nextInt() sc.nextInt sc min += array[i] min array[i] array i int T = 0; T 0 int t = 0; t 0 for (int i = 0; i < N; i++) {
			for (int j = 0; j < i; j++) {
				T += array[j];
			}
			for (int k = i; k < N; k++) {
				t += array[k];
			}
			int abs = Math.abs(T - t);
			if (abs < min) {
				min = abs;
			}
			t=0;
			T=0;
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			for (int j = 0; j < i; j++) {
				T += array[j];
			}
			for (int k = i; k < N; k++) {
				t += array[k];
			}
			int abs = Math.abs(T - t);
			if (abs < min) {
				min = abs;
			}
			t=0;
			T=0;
		} {
			for (int j = 0; j < i; j++) {
				T += array[j];
			}
			for (int k = i; k < N; k++) {
				t += array[k];
			}
			int abs = Math.abs(T - t);
			if (abs < min) {
				min = abs;
			}
			t=0;
			T=0;
		} for (int j = 0; j < i; j++) {
				T += array[j];
			} int j = 0; int j = 0; j 0 j < i j i j++ j++ j {
				T += array[j];
			} {
				T += array[j];
			} T += array[j] T array[j] array j for (int k = i; k < N; k++) {
				t += array[k];
			} int k = i; int k = i; k i k < N k N k++ k++ k {
				t += array[k];
			} {
				t += array[k];
			} t += array[k] t array[k] array k int abs = Math.abs(T - t); abs Math.abs(T - t) Math.abs Math T - t T t if (abs < min) {
				min = abs;
			} abs < min abs min {
				min = abs;
			} min = abs min abs t=0 t 0 T=0 T 0 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 sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] array = new int[N];
		int min = 0;
		for (int i = 0; i < N; i++) {
			array[i] = sc.nextInt();
			min += array[i];
		}

		int T = 0;
		int t = 0;
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < i; j++) {
				T += array[j];
			}
			for (int k = i; k < N; k++) {
				t += array[k];
			}
			int abs = Math.abs(T - t);
			if (abs < min) {
				min = abs;
			}
			t=0;
			T=0;
		}
		System.out.println(min);
	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] array = new int[N];
		int min = 0;
		for (int i = 0; i < N; i++) {
			array[i] = sc.nextInt();
			min += array[i];
		}

		int T = 0;
		int t = 0;
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < i; j++) {
				T += array[j];
			}
			for (int k = i; k < N; k++) {
				t += array[k];
			}
			int abs = Math.abs(T - t);
			if (abs < min) {
				min = abs;
			}
			t=0;
			T=0;
		}
		System.out.println(min);
	}

} 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[] array = new int[N];
		int min = 0;
		for (int i = 0; i < N; i++) {
			array[i] = sc.nextInt();
			min += array[i];
		}

		int T = 0;
		int t = 0;
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < i; j++) {
				T += array[j];
			}
			for (int k = i; k < N; k++) {
				t += array[k];
			}
			int abs = Math.abs(T - t);
			if (abs < min) {
				min = abs;
			}
			t=0;
			T=0;
		}
		System.out.println(min);
	}

}