
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		int ans = 100000;
		for(int i = 1; i <= n; i++) {
			int tmp1 = 0;
			int tmp2 = 0;
			for(int j = 0; j < n; j++) {
				if(j <= i) {
					tmp1 += a[j];
				}else {
					tmp2+= a[j];
				}
			}
			int tmp3 = Math.abs(tmp1-tmp2);
			ans = Math.min(ans, tmp3);
		}
		System.out.println(ans);
		sc.close();
	}
	
    
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		int ans = 100000;
		for(int i = 1; i <= n; i++) {
			int tmp1 = 0;
			int tmp2 = 0;
			for(int j = 0; j < n; j++) {
				if(j <= i) {
					tmp1 += a[j];
				}else {
					tmp2+= a[j];
				}
			}
			int tmp3 = Math.abs(tmp1-tmp2);
			ans = Math.min(ans, tmp3);
		}
		System.out.println(ans);
		sc.close();
	}
	
    
} Main public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		int ans = 100000;
		for(int i = 1; i <= n; i++) {
			int tmp1 = 0;
			int tmp2 = 0;
			for(int j = 0; j < n; j++) {
				if(j <= i) {
					tmp1 += a[j];
				}else {
					tmp2+= a[j];
				}
			}
			int tmp3 = Math.abs(tmp1-tmp2);
			ans = Math.min(ans, tmp3);
		}
		System.out.println(ans);
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		int ans = 100000;
		for(int i = 1; i <= n; i++) {
			int tmp1 = 0;
			int tmp2 = 0;
			for(int j = 0; j < n; j++) {
				if(j <= i) {
					tmp1 += a[j];
				}else {
					tmp2+= a[j];
				}
			}
			int tmp3 = Math.abs(tmp1-tmp2);
			ans = Math.min(ans, tmp3);
		}
		System.out.println(ans);
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] a = new int[n]; a new int[n] n for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			a[i] = sc.nextInt();
		} {
			a[i] = sc.nextInt();
		} a[i] = sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc int ans = 100000; ans 100000 for(int i = 1; i <= n; i++) {
			int tmp1 = 0;
			int tmp2 = 0;
			for(int j = 0; j < n; j++) {
				if(j <= i) {
					tmp1 += a[j];
				}else {
					tmp2+= a[j];
				}
			}
			int tmp3 = Math.abs(tmp1-tmp2);
			ans = Math.min(ans, tmp3);
		} int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
			int tmp1 = 0;
			int tmp2 = 0;
			for(int j = 0; j < n; j++) {
				if(j <= i) {
					tmp1 += a[j];
				}else {
					tmp2+= a[j];
				}
			}
			int tmp3 = Math.abs(tmp1-tmp2);
			ans = Math.min(ans, tmp3);
		} {
			int tmp1 = 0;
			int tmp2 = 0;
			for(int j = 0; j < n; j++) {
				if(j <= i) {
					tmp1 += a[j];
				}else {
					tmp2+= a[j];
				}
			}
			int tmp3 = Math.abs(tmp1-tmp2);
			ans = Math.min(ans, tmp3);
		} int tmp1 = 0; tmp1 0 int tmp2 = 0; tmp2 0 for(int j = 0; j < n; j++) {
				if(j <= i) {
					tmp1 += a[j];
				}else {
					tmp2+= a[j];
				}
			} int j = 0; int j = 0; j 0 j < n j n j++ j++ j {
				if(j <= i) {
					tmp1 += a[j];
				}else {
					tmp2+= a[j];
				}
			} {
				if(j <= i) {
					tmp1 += a[j];
				}else {
					tmp2+= a[j];
				}
			} if(j <= i) {
					tmp1 += a[j];
				}else {
					tmp2+= a[j];
				} j <= i j i {
					tmp1 += a[j];
				} tmp1 += a[j] tmp1 a[j] a j {
					tmp2+= a[j];
				} tmp2+= a[j] tmp2 a[j] a j int tmp3 = Math.abs(tmp1-tmp2); tmp3 Math.abs(tmp1-tmp2) Math.abs Math tmp1-tmp2 tmp1 tmp2 ans = Math.min(ans, tmp3) ans Math.min(ans, tmp3) Math.min Math ans tmp3 System.out.println(ans) System.out.println System.out System System.out ans sc.close() sc.close sc String[] args args public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		int ans = 100000;
		for(int i = 1; i <= n; i++) {
			int tmp1 = 0;
			int tmp2 = 0;
			for(int j = 0; j < n; j++) {
				if(j <= i) {
					tmp1 += a[j];
				}else {
					tmp2+= a[j];
				}
			}
			int tmp3 = Math.abs(tmp1-tmp2);
			ans = Math.min(ans, tmp3);
		}
		System.out.println(ans);
		sc.close();
	}
	
    
} public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		int ans = 100000;
		for(int i = 1; i <= n; i++) {
			int tmp1 = 0;
			int tmp2 = 0;
			for(int j = 0; j < n; j++) {
				if(j <= i) {
					tmp1 += a[j];
				}else {
					tmp2+= a[j];
				}
			}
			int tmp3 = Math.abs(tmp1-tmp2);
			ans = Math.min(ans, tmp3);
		}
		System.out.println(ans);
		sc.close();
	}
	
    
} Main

import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		int ans = 100000;
		for(int i = 1; i <= n; i++) {
			int tmp1 = 0;
			int tmp2 = 0;
			for(int j = 0; j < n; j++) {
				if(j <= i) {
					tmp1 += a[j];
				}else {
					tmp2+= a[j];
				}
			}
			int tmp3 = Math.abs(tmp1-tmp2);
			ans = Math.min(ans, tmp3);
		}
		System.out.println(ans);
		sc.close();
	}
	
    
}
