import java.util.Scanner;

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 s = 1000;
		for(int i=0; i<N; i++) {
			W[i] = sc.nextInt();
		}
		sc.close();
		for(int j=0; j<N; j++) {
			int s1 = 0;
			int s2 = 0;
			for(int i=0; i<j; i++) {
				s1 += W[i];
			}
			for(int i=j; i<N; i++) {
				s2 += W[i];
			}
			if( Math.abs(s1-s2) < s) {
				s = Math.abs(s1-s2);
			}
		}
		System.out.println(s);
	}

} 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[] W = new int[N];
		int s = 1000;
		for(int i=0; i<N; i++) {
			W[i] = sc.nextInt();
		}
		sc.close();
		for(int j=0; j<N; j++) {
			int s1 = 0;
			int s2 = 0;
			for(int i=0; i<j; i++) {
				s1 += W[i];
			}
			for(int i=j; i<N; i++) {
				s2 += W[i];
			}
			if( Math.abs(s1-s2) < s) {
				s = Math.abs(s1-s2);
			}
		}
		System.out.println(s);
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] W = new int[N];
		int s = 1000;
		for(int i=0; i<N; i++) {
			W[i] = sc.nextInt();
		}
		sc.close();
		for(int j=0; j<N; j++) {
			int s1 = 0;
			int s2 = 0;
			for(int i=0; i<j; i++) {
				s1 += W[i];
			}
			for(int i=j; i<N; i++) {
				s2 += W[i];
			}
			if( Math.abs(s1-s2) < s) {
				s = Math.abs(s1-s2);
			}
		}
		System.out.println(s);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] W = new int[N];
		int s = 1000;
		for(int i=0; i<N; i++) {
			W[i] = sc.nextInt();
		}
		sc.close();
		for(int j=0; j<N; j++) {
			int s1 = 0;
			int s2 = 0;
			for(int i=0; i<j; i++) {
				s1 += W[i];
			}
			for(int i=j; i<N; i++) {
				s2 += W[i];
			}
			if( Math.abs(s1-s2) < s) {
				s = Math.abs(s1-s2);
			}
		}
		System.out.println(s);
	} 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 s = 1000; s 1000 for(int i=0; i<N; i++) {
			W[i] = sc.nextInt();
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			W[i] = sc.nextInt();
		} {
			W[i] = sc.nextInt();
		} W[i] = sc.nextInt() W[i] W i sc.nextInt() sc.nextInt sc sc.close() sc.close sc for(int j=0; j<N; j++) {
			int s1 = 0;
			int s2 = 0;
			for(int i=0; i<j; i++) {
				s1 += W[i];
			}
			for(int i=j; i<N; i++) {
				s2 += W[i];
			}
			if( Math.abs(s1-s2) < s) {
				s = Math.abs(s1-s2);
			}
		} int j=0; int j=0; j 0 j<N j N j++ j++ j {
			int s1 = 0;
			int s2 = 0;
			for(int i=0; i<j; i++) {
				s1 += W[i];
			}
			for(int i=j; i<N; i++) {
				s2 += W[i];
			}
			if( Math.abs(s1-s2) < s) {
				s = Math.abs(s1-s2);
			}
		} {
			int s1 = 0;
			int s2 = 0;
			for(int i=0; i<j; i++) {
				s1 += W[i];
			}
			for(int i=j; i<N; i++) {
				s2 += W[i];
			}
			if( Math.abs(s1-s2) < s) {
				s = Math.abs(s1-s2);
			}
		} int s1 = 0; s1 0 int s2 = 0; s2 0 for(int i=0; i<j; i++) {
				s1 += W[i];
			} int i=0; int i=0; i 0 i<j i j i++ i++ i {
				s1 += W[i];
			} {
				s1 += W[i];
			} s1 += W[i] s1 W[i] W i for(int i=j; i<N; i++) {
				s2 += W[i];
			} int i=j; int i=j; i j i<N i N i++ i++ i {
				s2 += W[i];
			} {
				s2 += W[i];
			} s2 += W[i] s2 W[i] W i if( Math.abs(s1-s2) < s) {
				s = Math.abs(s1-s2);
			} Math.abs(s1-s2) < s Math.abs(s1-s2) Math.abs Math s1-s2 s1 s2 s {
				s = Math.abs(s1-s2);
			} s = Math.abs(s1-s2) s Math.abs(s1-s2) Math.abs Math s1-s2 s1 s2 System.out.println(s) System.out.println System.out System System.out s 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 s = 1000;
		for(int i=0; i<N; i++) {
			W[i] = sc.nextInt();
		}
		sc.close();
		for(int j=0; j<N; j++) {
			int s1 = 0;
			int s2 = 0;
			for(int i=0; i<j; i++) {
				s1 += W[i];
			}
			for(int i=j; i<N; i++) {
				s2 += W[i];
			}
			if( Math.abs(s1-s2) < s) {
				s = Math.abs(s1-s2);
			}
		}
		System.out.println(s);
	}

} 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 s = 1000;
		for(int i=0; i<N; i++) {
			W[i] = sc.nextInt();
		}
		sc.close();
		for(int j=0; j<N; j++) {
			int s1 = 0;
			int s2 = 0;
			for(int i=0; i<j; i++) {
				s1 += W[i];
			}
			for(int i=j; i<N; i++) {
				s2 += W[i];
			}
			if( Math.abs(s1-s2) < s) {
				s = Math.abs(s1-s2);
			}
		}
		System.out.println(s);
	}

} 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[] W = new int[N];
		int s = 1000;
		for(int i=0; i<N; i++) {
			W[i] = sc.nextInt();
		}
		sc.close();
		for(int j=0; j<N; j++) {
			int s1 = 0;
			int s2 = 0;
			for(int i=0; i<j; i++) {
				s1 += W[i];
			}
			for(int i=j; i<N; i++) {
				s2 += W[i];
			}
			if( Math.abs(s1-s2) < s) {
				s = Math.abs(s1-s2);
			}
		}
		System.out.println(s);
	}

}