import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}

		int left = 0;
		int right = 0;
		int diffMin = 1000;

		for (int i = 1; i < n; i++) {
			for (int j = 0; j < i; j++) {
				left += a[j];
			}
			for (int j = i; j < n; j++) {
				right += a[j];
			}
			if (Math.abs(left - right) < diffMin) {
				diffMin = Math.abs(left - right);
			}

			left = 0;
			right = 0;
		}

		System.out.println(diffMin);

	}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}

		int left = 0;
		int right = 0;
		int diffMin = 1000;

		for (int i = 1; i < n; i++) {
			for (int j = 0; j < i; j++) {
				left += a[j];
			}
			for (int j = i; j < n; j++) {
				right += a[j];
			}
			if (Math.abs(left - right) < diffMin) {
				diffMin = Math.abs(left - right);
			}

			left = 0;
			right = 0;
		}

		System.out.println(diffMin);

	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}

		int left = 0;
		int right = 0;
		int diffMin = 1000;

		for (int i = 1; i < n; i++) {
			for (int j = 0; j < i; j++) {
				left += a[j];
			}
			for (int j = i; j < n; j++) {
				right += a[j];
			}
			if (Math.abs(left - right) < diffMin) {
				diffMin = Math.abs(left - right);
			}

			left = 0;
			right = 0;
		}

		System.out.println(diffMin);

	} main {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}

		int left = 0;
		int right = 0;
		int diffMin = 1000;

		for (int i = 1; i < n; i++) {
			for (int j = 0; j < i; j++) {
				left += a[j];
			}
			for (int j = i; j < n; j++) {
				right += a[j];
			}
			if (Math.abs(left - right) < diffMin) {
				diffMin = Math.abs(left - right);
			}

			left = 0;
			right = 0;
		}

		System.out.println(diffMin);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int[] a = new int[n]; a new int[n] n for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			a[i] = Integer.parseInt(sc.next());
		} {
			a[i] = Integer.parseInt(sc.next());
		} a[i] = Integer.parseInt(sc.next()) a[i] a i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int left = 0; left 0 int right = 0; right 0 int diffMin = 1000; diffMin 1000 for (int i = 1; i < n; i++) {
			for (int j = 0; j < i; j++) {
				left += a[j];
			}
			for (int j = i; j < n; j++) {
				right += a[j];
			}
			if (Math.abs(left - right) < diffMin) {
				diffMin = Math.abs(left - right);
			}

			left = 0;
			right = 0;
		} int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
			for (int j = 0; j < i; j++) {
				left += a[j];
			}
			for (int j = i; j < n; j++) {
				right += a[j];
			}
			if (Math.abs(left - right) < diffMin) {
				diffMin = Math.abs(left - right);
			}

			left = 0;
			right = 0;
		} {
			for (int j = 0; j < i; j++) {
				left += a[j];
			}
			for (int j = i; j < n; j++) {
				right += a[j];
			}
			if (Math.abs(left - right) < diffMin) {
				diffMin = Math.abs(left - right);
			}

			left = 0;
			right = 0;
		} for (int j = 0; j < i; j++) {
				left += a[j];
			} int j = 0; int j = 0; j 0 j < i j i j++ j++ j {
				left += a[j];
			} {
				left += a[j];
			} left += a[j] left a[j] a j for (int j = i; j < n; j++) {
				right += a[j];
			} int j = i; int j = i; j i j < n j n j++ j++ j {
				right += a[j];
			} {
				right += a[j];
			} right += a[j] right a[j] a j if (Math.abs(left - right) < diffMin) {
				diffMin = Math.abs(left - right);
			} Math.abs(left - right) < diffMin Math.abs(left - right) Math.abs Math left - right left right diffMin {
				diffMin = Math.abs(left - right);
			} diffMin = Math.abs(left - right) diffMin Math.abs(left - right) Math.abs Math left - right left right left = 0 left 0 right = 0 right 0 System.out.println(diffMin) System.out.println System.out System System.out diffMin String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}

		int left = 0;
		int right = 0;
		int diffMin = 1000;

		for (int i = 1; i < n; i++) {
			for (int j = 0; j < i; j++) {
				left += a[j];
			}
			for (int j = i; j < n; j++) {
				right += a[j];
			}
			if (Math.abs(left - right) < diffMin) {
				diffMin = Math.abs(left - right);
			}

			left = 0;
			right = 0;
		}

		System.out.println(diffMin);

	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}

		int left = 0;
		int right = 0;
		int diffMin = 1000;

		for (int i = 1; i < n; i++) {
			for (int j = 0; j < i; j++) {
				left += a[j];
			}
			for (int j = i; j < n; j++) {
				right += a[j];
			}
			if (Math.abs(left - right) < diffMin) {
				diffMin = Math.abs(left - right);
			}

			left = 0;
			right = 0;
		}

		System.out.println(diffMin);

	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}

		int left = 0;
		int right = 0;
		int diffMin = 1000;

		for (int i = 1; i < n; i++) {
			for (int j = 0; j < i; j++) {
				left += a[j];
			}
			for (int j = i; j < n; j++) {
				right += a[j];
			}
			if (Math.abs(left - right) < diffMin) {
				diffMin = Math.abs(left - right);
			}

			left = 0;
			right = 0;
		}

		System.out.println(diffMin);

	}

}
