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 s1 = 0, s2 = 0, min = Integer.MAX_VALUE;
		for(int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			s2 += W[i];
		}
		sc.close();
		for(int i = 0; i < N; i++) {
			s1 += W[i];
			s2 -= W[i];
			int abs = Math.abs(s1 - s2);
			if(abs < min) min = abs;
		}
		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[] W = new int[N];
		int s1 = 0, s2 = 0, min = Integer.MAX_VALUE;
		for(int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			s2 += W[i];
		}
		sc.close();
		for(int i = 0; i < N; i++) {
			s1 += W[i];
			s2 -= W[i];
			int abs = Math.abs(s1 - s2);
			if(abs < min) min = abs;
		}
		System.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 s1 = 0, s2 = 0, min = Integer.MAX_VALUE;
		for(int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			s2 += W[i];
		}
		sc.close();
		for(int i = 0; i < N; i++) {
			s1 += W[i];
			s2 -= W[i];
			int abs = Math.abs(s1 - s2);
			if(abs < min) min = abs;
		}
		System.out.println(min);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] W = new int[N];
		int s1 = 0, s2 = 0, min = Integer.MAX_VALUE;
		for(int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			s2 += W[i];
		}
		sc.close();
		for(int i = 0; i < N; i++) {
			s1 += W[i];
			s2 -= W[i];
			int abs = Math.abs(s1 - s2);
			if(abs < min) min = abs;
		}
		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[] W = new int[N]; W new int[N] N int s1 = 0 s1 0 s2 = 0 s2 0 min = Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE for(int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			s2 += W[i];
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			W[i] = sc.nextInt();
			s2 += W[i];
		} {
			W[i] = sc.nextInt();
			s2 += W[i];
		} W[i] = sc.nextInt() W[i] W i sc.nextInt() sc.nextInt sc s2 += W[i] s2 W[i] W i sc.close() sc.close sc for(int i = 0; i < N; i++) {
			s1 += W[i];
			s2 -= W[i];
			int abs = Math.abs(s1 - s2);
			if(abs < min) min = abs;
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			s1 += W[i];
			s2 -= W[i];
			int abs = Math.abs(s1 - s2);
			if(abs < min) min = abs;
		} {
			s1 += W[i];
			s2 -= W[i];
			int abs = Math.abs(s1 - s2);
			if(abs < min) min = abs;
		} s1 += W[i] s1 W[i] W i s2 -= W[i] s2 W[i] W i int abs = Math.abs(s1 - s2); abs Math.abs(s1 - s2) Math.abs Math s1 - s2 s1 s2 if(abs < min) min = abs; abs < min abs min min = abs min abs 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[] W = new int[N];
		int s1 = 0, s2 = 0, min = Integer.MAX_VALUE;
		for(int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			s2 += W[i];
		}
		sc.close();
		for(int i = 0; i < N; i++) {
			s1 += W[i];
			s2 -= W[i];
			int abs = Math.abs(s1 - s2);
			if(abs < min) min = abs;
		}
		System.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 s1 = 0, s2 = 0, min = Integer.MAX_VALUE;
		for(int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			s2 += W[i];
		}
		sc.close();
		for(int i = 0; i < N; i++) {
			s1 += W[i];
			s2 -= W[i];
			int abs = Math.abs(s1 - s2);
			if(abs < min) min = abs;
		}
		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[] W = new int[N];
		int s1 = 0, s2 = 0, min = Integer.MAX_VALUE;
		for(int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			s2 += W[i];
		}
		sc.close();
		for(int i = 0; i < N; i++) {
			s1 += W[i];
			s2 -= W[i];
			int abs = Math.abs(s1 - s2);
			if(abs < min) min = abs;
		}
		System.out.println(min);
	}
}
