import java.util.*;
import static java.lang.System.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] w = new int[n];
		int sum = 0;
		for(int i =0; i < n; i++) {
			w[i] = sc.nextInt();
			sum += w[i];
		}
		int min = Integer.MAX_VALUE / 10;
		for(int i = 1; i < n; i++) {
			int a = 0; int b = 0;
			for(int j = 0; j < i; j++) {
				a += w[j];
			}
			b = sum - a;
			int score = Math.abs(a - b);
			if (min > score)min = score;
		}
		out.println(min);
		
	}
} import java.util.*; util.* java import static java.lang.System.*; import static java.lang.System.*; import static java.lang.System.*; public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] w = new int[n];
		int sum = 0;
		for(int i =0; i < n; i++) {
			w[i] = sc.nextInt();
			sum += w[i];
		}
		int min = Integer.MAX_VALUE / 10;
		for(int i = 1; i < n; i++) {
			int a = 0; int b = 0;
			for(int j = 0; j < i; j++) {
				a += w[j];
			}
			b = sum - a;
			int score = Math.abs(a - b);
			if (min > score)min = score;
		}
		out.println(min);
		
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] w = new int[n];
		int sum = 0;
		for(int i =0; i < n; i++) {
			w[i] = sc.nextInt();
			sum += w[i];
		}
		int min = Integer.MAX_VALUE / 10;
		for(int i = 1; i < n; i++) {
			int a = 0; int b = 0;
			for(int j = 0; j < i; j++) {
				a += w[j];
			}
			b = sum - a;
			int score = Math.abs(a - b);
			if (min > score)min = score;
		}
		out.println(min);
		
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] w = new int[n];
		int sum = 0;
		for(int i =0; i < n; i++) {
			w[i] = sc.nextInt();
			sum += w[i];
		}
		int min = Integer.MAX_VALUE / 10;
		for(int i = 1; i < n; i++) {
			int a = 0; int b = 0;
			for(int j = 0; j < i; j++) {
				a += w[j];
			}
			b = sum - a;
			int score = Math.abs(a - b);
			if (min > score)min = score;
		}
		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[] w = new int[n]; w new int[n] n int sum = 0; sum 0 for(int i =0; i < n; i++) {
			w[i] = sc.nextInt();
			sum += w[i];
		} int i =0; int i =0; i 0 i < n i n i++ i++ i {
			w[i] = sc.nextInt();
			sum += w[i];
		} {
			w[i] = sc.nextInt();
			sum += w[i];
		} w[i] = sc.nextInt() w[i] w i sc.nextInt() sc.nextInt sc sum += w[i] sum w[i] w i int min = Integer.MAX_VALUE / 10; min Integer.MAX_VALUE / 10 Integer.MAX_VALUE Integer Integer.MAX_VALUE 10 for(int i = 1; i < n; i++) {
			int a = 0; int b = 0;
			for(int j = 0; j < i; j++) {
				a += w[j];
			}
			b = sum - a;
			int score = Math.abs(a - b);
			if (min > score)min = score;
		} int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
			int a = 0; int b = 0;
			for(int j = 0; j < i; j++) {
				a += w[j];
			}
			b = sum - a;
			int score = Math.abs(a - b);
			if (min > score)min = score;
		} {
			int a = 0; int b = 0;
			for(int j = 0; j < i; j++) {
				a += w[j];
			}
			b = sum - a;
			int score = Math.abs(a - b);
			if (min > score)min = score;
		} int a = 0; a 0 int b = 0; b 0 for(int j = 0; j < i; j++) {
				a += w[j];
			} int j = 0; int j = 0; j 0 j < i j i j++ j++ j {
				a += w[j];
			} {
				a += w[j];
			} a += w[j] a w[j] w j b = sum - a b sum - a sum a int score = Math.abs(a - b); score Math.abs(a - b) Math.abs Math a - b a b if (min > score)min = score; min > score min score min = score min score out.println(min) out.println 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[] w = new int[n];
		int sum = 0;
		for(int i =0; i < n; i++) {
			w[i] = sc.nextInt();
			sum += w[i];
		}
		int min = Integer.MAX_VALUE / 10;
		for(int i = 1; i < n; i++) {
			int a = 0; int b = 0;
			for(int j = 0; j < i; j++) {
				a += w[j];
			}
			b = sum - a;
			int score = Math.abs(a - b);
			if (min > score)min = score;
		}
		out.println(min);
		
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] w = new int[n];
		int sum = 0;
		for(int i =0; i < n; i++) {
			w[i] = sc.nextInt();
			sum += w[i];
		}
		int min = Integer.MAX_VALUE / 10;
		for(int i = 1; i < n; i++) {
			int a = 0; int b = 0;
			for(int j = 0; j < i; j++) {
				a += w[j];
			}
			b = sum - a;
			int score = Math.abs(a - b);
			if (min > score)min = score;
		}
		out.println(min);
		
	}
} Main
import java.util.*;
import static java.lang.System.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] w = new int[n];
		int sum = 0;
		for(int i =0; i < n; i++) {
			w[i] = sc.nextInt();
			sum += w[i];
		}
		int min = Integer.MAX_VALUE / 10;
		for(int i = 1; i < n; i++) {
			int a = 0; int b = 0;
			for(int j = 0; j < i; j++) {
				a += w[j];
			}
			b = sum - a;
			int score = Math.abs(a - b);
			if (min > score)min = score;
		}
		out.println(min);
		
	}
}