// Balance_128_B

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] W = new int[N];
		int[] sub = new int[N];
		int ans;

		for(int i=0;i<N;i++) {
			W[i] = scan.nextInt();
			}

		for(int i=0;i<N;i++) {
			int S1=0,S2=0;
			for(int k=i;k>=0;k--) {
				S1 = S1 + W[k];
			}
			for(int k=i+1;k<N;k++) {
				S2 = S2 + W[k];
			}
//			System.out.println(i+"回目, S1, S2="+S1+", "+S2);
			sub[i] = Math.abs(S1-S2);
		}

		ans = sub[0];

		for(int n:sub) {
			if(ans>n) {
				ans = n;
			}
		}

//		for(int n:sub) {
//			System.out.print(n+" ");
//		}

		System.out.println(ans);

		scan.close();
	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] W = new int[N];
		int[] sub = new int[N];
		int ans;

		for(int i=0;i<N;i++) {
			W[i] = scan.nextInt();
			}

		for(int i=0;i<N;i++) {
			int S1=0,S2=0;
			for(int k=i;k>=0;k--) {
				S1 = S1 + W[k];
			}
			for(int k=i+1;k<N;k++) {
				S2 = S2 + W[k];
			}
//			System.out.println(i+"回目, S1, S2="+S1+", "+S2);
			sub[i] = Math.abs(S1-S2);
		}

		ans = sub[0];

		for(int n:sub) {
			if(ans>n) {
				ans = n;
			}
		}

//		for(int n:sub) {
//			System.out.print(n+" ");
//		}

		System.out.println(ans);

		scan.close();
	}

} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] W = new int[N];
		int[] sub = new int[N];
		int ans;

		for(int i=0;i<N;i++) {
			W[i] = scan.nextInt();
			}

		for(int i=0;i<N;i++) {
			int S1=0,S2=0;
			for(int k=i;k>=0;k--) {
				S1 = S1 + W[k];
			}
			for(int k=i+1;k<N;k++) {
				S2 = S2 + W[k];
			}
//			System.out.println(i+"回目, S1, S2="+S1+", "+S2);
			sub[i] = Math.abs(S1-S2);
		}

		ans = sub[0];

		for(int n:sub) {
			if(ans>n) {
				ans = n;
			}
		}

//		for(int n:sub) {
//			System.out.print(n+" ");
//		}

		System.out.println(ans);

		scan.close();
	} main {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] W = new int[N];
		int[] sub = new int[N];
		int ans;

		for(int i=0;i<N;i++) {
			W[i] = scan.nextInt();
			}

		for(int i=0;i<N;i++) {
			int S1=0,S2=0;
			for(int k=i;k>=0;k--) {
				S1 = S1 + W[k];
			}
			for(int k=i+1;k<N;k++) {
				S2 = S2 + W[k];
			}
//			System.out.println(i+"回目, S1, S2="+S1+", "+S2);
			sub[i] = Math.abs(S1-S2);
		}

		ans = sub[0];

		for(int n:sub) {
			if(ans>n) {
				ans = n;
			}
		}

//		for(int n:sub) {
//			System.out.print(n+" ");
//		}

		System.out.println(ans);

		scan.close();
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan int[] W = new int[N]; W new int[N] N int[] sub = new int[N]; sub new int[N] N int ans; ans for(int i=0;i<N;i++) {
			W[i] = scan.nextInt();
			} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			W[i] = scan.nextInt();
			} {
			W[i] = scan.nextInt();
			} W[i] = scan.nextInt() W[i] W i scan.nextInt() scan.nextInt scan for(int i=0;i<N;i++) {
			int S1=0,S2=0;
			for(int k=i;k>=0;k--) {
				S1 = S1 + W[k];
			}
			for(int k=i+1;k<N;k++) {
				S2 = S2 + W[k];
			}
//			System.out.println(i+"回目, S1, S2="+S1+", "+S2);
			sub[i] = Math.abs(S1-S2);
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			int S1=0,S2=0;
			for(int k=i;k>=0;k--) {
				S1 = S1 + W[k];
			}
			for(int k=i+1;k<N;k++) {
				S2 = S2 + W[k];
			}
//			System.out.println(i+"回目, S1, S2="+S1+", "+S2);
			sub[i] = Math.abs(S1-S2);
		} {
			int S1=0,S2=0;
			for(int k=i;k>=0;k--) {
				S1 = S1 + W[k];
			}
			for(int k=i+1;k<N;k++) {
				S2 = S2 + W[k];
			}
//			System.out.println(i+"回目, S1, S2="+S1+", "+S2);
			sub[i] = Math.abs(S1-S2);
		} int S1=0 S1 0 S2=0; S2 0 for(int k=i;k>=0;k--) {
				S1 = S1 + W[k];
			} int k=i; int k=i; k i k>=0 k 0 k-- k-- k {
				S1 = S1 + W[k];
			} {
				S1 = S1 + W[k];
			} S1 = S1 + W[k] S1 S1 + W[k] S1 W[k] W k for(int k=i+1;k<N;k++) {
				S2 = S2 + W[k];
			} int k=i+1; int k=i+1; k i+1 i 1 k<N k N k++ k++ k {
				S2 = S2 + W[k];
			} {
				S2 = S2 + W[k];
			} S2 = S2 + W[k] S2 S2 + W[k] S2 W[k] W k sub[i] = Math.abs(S1-S2) sub[i] sub i Math.abs(S1-S2) Math.abs Math S1-S2 S1 S2 ans = sub[0] ans sub[0] sub 0 for(int n:sub) {
			if(ans>n) {
				ans = n;
			}
		} int n sub {
			if(ans>n) {
				ans = n;
			}
		} {
			if(ans>n) {
				ans = n;
			}
		} if(ans>n) {
				ans = n;
			} ans>n ans n {
				ans = n;
			} ans = n ans n System.out.println(ans) System.out.println System.out System System.out ans scan.close() scan.close scan String[] args args public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] W = new int[N];
		int[] sub = new int[N];
		int ans;

		for(int i=0;i<N;i++) {
			W[i] = scan.nextInt();
			}

		for(int i=0;i<N;i++) {
			int S1=0,S2=0;
			for(int k=i;k>=0;k--) {
				S1 = S1 + W[k];
			}
			for(int k=i+1;k<N;k++) {
				S2 = S2 + W[k];
			}
//			System.out.println(i+"回目, S1, S2="+S1+", "+S2);
			sub[i] = Math.abs(S1-S2);
		}

		ans = sub[0];

		for(int n:sub) {
			if(ans>n) {
				ans = n;
			}
		}

//		for(int n:sub) {
//			System.out.print(n+" ");
//		}

		System.out.println(ans);

		scan.close();
	}

} public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] W = new int[N];
		int[] sub = new int[N];
		int ans;

		for(int i=0;i<N;i++) {
			W[i] = scan.nextInt();
			}

		for(int i=0;i<N;i++) {
			int S1=0,S2=0;
			for(int k=i;k>=0;k--) {
				S1 = S1 + W[k];
			}
			for(int k=i+1;k<N;k++) {
				S2 = S2 + W[k];
			}
//			System.out.println(i+"回目, S1, S2="+S1+", "+S2);
			sub[i] = Math.abs(S1-S2);
		}

		ans = sub[0];

		for(int n:sub) {
			if(ans>n) {
				ans = n;
			}
		}

//		for(int n:sub) {
//			System.out.print(n+" ");
//		}

		System.out.println(ans);

		scan.close();
	}

} Main
// Balance_128_B

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] W = new int[N];
		int[] sub = new int[N];
		int ans;

		for(int i=0;i<N;i++) {
			W[i] = scan.nextInt();
			}

		for(int i=0;i<N;i++) {
			int S1=0,S2=0;
			for(int k=i;k>=0;k--) {
				S1 = S1 + W[k];
			}
			for(int k=i+1;k<N;k++) {
				S2 = S2 + W[k];
			}
//			System.out.println(i+"回目, S1, S2="+S1+", "+S2);
			sub[i] = Math.abs(S1-S2);
		}

		ans = sub[0];

		for(int n:sub) {
			if(ans>n) {
				ans = n;
			}
		}

//		for(int n:sub) {
//			System.out.print(n+" ");
//		}

		System.out.println(ans);

		scan.close();
	}

}
