import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);

		int n = scn.nextInt();
		int[] ws = new int[n];

		for (int i = 0; i < n; i++) {
			ws[i] = scn.nextInt();

		}

		scn.close();

		int min = 10001;
		for (int i = 0; i < n; i++) {
			int sum1 = 0;
			int sum2 = 0;
			for (int j = 0; j < i; j++) {
				sum1 += ws[j];
			}
			for (int j = i; j < n; j++) {
				sum2 += ws[j];
			}

			int dif = Math.abs(sum1 - sum2);

			if (dif < min) {
				min = dif;
			}

		}

		System.out.println(min);

	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);

		int n = scn.nextInt();
		int[] ws = new int[n];

		for (int i = 0; i < n; i++) {
			ws[i] = scn.nextInt();

		}

		scn.close();

		int min = 10001;
		for (int i = 0; i < n; i++) {
			int sum1 = 0;
			int sum2 = 0;
			for (int j = 0; j < i; j++) {
				sum1 += ws[j];
			}
			for (int j = i; j < n; j++) {
				sum2 += ws[j];
			}

			int dif = Math.abs(sum1 - sum2);

			if (dif < min) {
				min = dif;
			}

		}

		System.out.println(min);

	}
} Main public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);

		int n = scn.nextInt();
		int[] ws = new int[n];

		for (int i = 0; i < n; i++) {
			ws[i] = scn.nextInt();

		}

		scn.close();

		int min = 10001;
		for (int i = 0; i < n; i++) {
			int sum1 = 0;
			int sum2 = 0;
			for (int j = 0; j < i; j++) {
				sum1 += ws[j];
			}
			for (int j = i; j < n; j++) {
				sum2 += ws[j];
			}

			int dif = Math.abs(sum1 - sum2);

			if (dif < min) {
				min = dif;
			}

		}

		System.out.println(min);

	} main {
		Scanner scn = new Scanner(System.in);

		int n = scn.nextInt();
		int[] ws = new int[n];

		for (int i = 0; i < n; i++) {
			ws[i] = scn.nextInt();

		}

		scn.close();

		int min = 10001;
		for (int i = 0; i < n; i++) {
			int sum1 = 0;
			int sum2 = 0;
			for (int j = 0; j < i; j++) {
				sum1 += ws[j];
			}
			for (int j = i; j < n; j++) {
				sum2 += ws[j];
			}

			int dif = Math.abs(sum1 - sum2);

			if (dif < min) {
				min = dif;
			}

		}

		System.out.println(min);

	} Scanner scn = new Scanner(System.in); scn new Scanner(System.in) int n = scn.nextInt(); n scn.nextInt() scn.nextInt scn int[] ws = new int[n]; ws new int[n] n for (int i = 0; i < n; i++) {
			ws[i] = scn.nextInt();

		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			ws[i] = scn.nextInt();

		} {
			ws[i] = scn.nextInt();

		} ws[i] = scn.nextInt() ws[i] ws i scn.nextInt() scn.nextInt scn scn.close() scn.close scn int min = 10001; min 10001 for (int i = 0; i < n; i++) {
			int sum1 = 0;
			int sum2 = 0;
			for (int j = 0; j < i; j++) {
				sum1 += ws[j];
			}
			for (int j = i; j < n; j++) {
				sum2 += ws[j];
			}

			int dif = Math.abs(sum1 - sum2);

			if (dif < min) {
				min = dif;
			}

		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			int sum1 = 0;
			int sum2 = 0;
			for (int j = 0; j < i; j++) {
				sum1 += ws[j];
			}
			for (int j = i; j < n; j++) {
				sum2 += ws[j];
			}

			int dif = Math.abs(sum1 - sum2);

			if (dif < min) {
				min = dif;
			}

		} {
			int sum1 = 0;
			int sum2 = 0;
			for (int j = 0; j < i; j++) {
				sum1 += ws[j];
			}
			for (int j = i; j < n; j++) {
				sum2 += ws[j];
			}

			int dif = Math.abs(sum1 - sum2);

			if (dif < min) {
				min = dif;
			}

		} int sum1 = 0; sum1 0 int sum2 = 0; sum2 0 for (int j = 0; j < i; j++) {
				sum1 += ws[j];
			} int j = 0; int j = 0; j 0 j < i j i j++ j++ j {
				sum1 += ws[j];
			} {
				sum1 += ws[j];
			} sum1 += ws[j] sum1 ws[j] ws j for (int j = i; j < n; j++) {
				sum2 += ws[j];
			} int j = i; int j = i; j i j < n j n j++ j++ j {
				sum2 += ws[j];
			} {
				sum2 += ws[j];
			} sum2 += ws[j] sum2 ws[j] ws j int dif = Math.abs(sum1 - sum2); dif Math.abs(sum1 - sum2) Math.abs Math sum1 - sum2 sum1 sum2 if (dif < min) {
				min = dif;
			} dif < min dif min {
				min = dif;
			} min = dif min dif 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 scn = new Scanner(System.in);

		int n = scn.nextInt();
		int[] ws = new int[n];

		for (int i = 0; i < n; i++) {
			ws[i] = scn.nextInt();

		}

		scn.close();

		int min = 10001;
		for (int i = 0; i < n; i++) {
			int sum1 = 0;
			int sum2 = 0;
			for (int j = 0; j < i; j++) {
				sum1 += ws[j];
			}
			for (int j = i; j < n; j++) {
				sum2 += ws[j];
			}

			int dif = Math.abs(sum1 - sum2);

			if (dif < min) {
				min = dif;
			}

		}

		System.out.println(min);

	}
} public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);

		int n = scn.nextInt();
		int[] ws = new int[n];

		for (int i = 0; i < n; i++) {
			ws[i] = scn.nextInt();

		}

		scn.close();

		int min = 10001;
		for (int i = 0; i < n; i++) {
			int sum1 = 0;
			int sum2 = 0;
			for (int j = 0; j < i; j++) {
				sum1 += ws[j];
			}
			for (int j = i; j < n; j++) {
				sum2 += ws[j];
			}

			int dif = Math.abs(sum1 - sum2);

			if (dif < min) {
				min = dif;
			}

		}

		System.out.println(min);

	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);

		int n = scn.nextInt();
		int[] ws = new int[n];

		for (int i = 0; i < n; i++) {
			ws[i] = scn.nextInt();

		}

		scn.close();

		int min = 10001;
		for (int i = 0; i < n; i++) {
			int sum1 = 0;
			int sum2 = 0;
			for (int j = 0; j < i; j++) {
				sum1 += ws[j];
			}
			for (int j = i; j < n; j++) {
				sum2 += ws[j];
			}

			int dif = Math.abs(sum1 - sum2);

			if (dif < min) {
				min = dif;
			}

		}

		System.out.println(min);

	}
}