import java.util.Scanner;

/**
 * 2019/06/09
 * AtCoder Beginner Contest 129
 * 
 * B - Balance
 * 
 * @author rued97
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] Ws = new int[N];
		for(int i = 0; i < N; i++) {
			Ws[i] = sc.nextInt();
		}
		
		int S1 = 0;
		int S2 = 0;
		int S1i = 0;
		int S2i = N - 1;
		
		while(S1i <= S2i) {
			if(S1 < S2) {
				S1 += Ws[S1i];
				S1i++;
			} else {
				S2 += Ws[S2i];
				S2i--;
			}
		}
		
		int result;
		if(S1 > S2) {
			result = S1 - S2;
		} else {
			result = S2 - S1;
		}

		System.out.println(result);
	}
	
} 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[] Ws = new int[N];
		for(int i = 0; i < N; i++) {
			Ws[i] = sc.nextInt();
		}
		
		int S1 = 0;
		int S2 = 0;
		int S1i = 0;
		int S2i = N - 1;
		
		while(S1i <= S2i) {
			if(S1 < S2) {
				S1 += Ws[S1i];
				S1i++;
			} else {
				S2 += Ws[S2i];
				S2i--;
			}
		}
		
		int result;
		if(S1 > S2) {
			result = S1 - S2;
		} else {
			result = S2 - S1;
		}

		System.out.println(result);
	}
	
} Main public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] Ws = new int[N];
		for(int i = 0; i < N; i++) {
			Ws[i] = sc.nextInt();
		}
		
		int S1 = 0;
		int S2 = 0;
		int S1i = 0;
		int S2i = N - 1;
		
		while(S1i <= S2i) {
			if(S1 < S2) {
				S1 += Ws[S1i];
				S1i++;
			} else {
				S2 += Ws[S2i];
				S2i--;
			}
		}
		
		int result;
		if(S1 > S2) {
			result = S1 - S2;
		} else {
			result = S2 - S1;
		}

		System.out.println(result);
	} main {
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] Ws = new int[N];
		for(int i = 0; i < N; i++) {
			Ws[i] = sc.nextInt();
		}
		
		int S1 = 0;
		int S2 = 0;
		int S1i = 0;
		int S2i = N - 1;
		
		while(S1i <= S2i) {
			if(S1 < S2) {
				S1 += Ws[S1i];
				S1i++;
			} else {
				S2 += Ws[S2i];
				S2i--;
			}
		}
		
		int result;
		if(S1 > S2) {
			result = S1 - S2;
		} else {
			result = S2 - S1;
		}

		System.out.println(result);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] Ws = new int[N]; Ws new int[N] N for(int i = 0; i < N; i++) {
			Ws[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			Ws[i] = sc.nextInt();
		} {
			Ws[i] = sc.nextInt();
		} Ws[i] = sc.nextInt() Ws[i] Ws i sc.nextInt() sc.nextInt sc int S1 = 0; S1 0 int S2 = 0; S2 0 int S1i = 0; S1i 0 int S2i = N - 1; S2i N - 1 N 1 while(S1i <= S2i) {
			if(S1 < S2) {
				S1 += Ws[S1i];
				S1i++;
			} else {
				S2 += Ws[S2i];
				S2i--;
			}
		} S1i <= S2i S1i S2i {
			if(S1 < S2) {
				S1 += Ws[S1i];
				S1i++;
			} else {
				S2 += Ws[S2i];
				S2i--;
			}
		} if(S1 < S2) {
				S1 += Ws[S1i];
				S1i++;
			} else {
				S2 += Ws[S2i];
				S2i--;
			} S1 < S2 S1 S2 {
				S1 += Ws[S1i];
				S1i++;
			} S1 += Ws[S1i] S1 Ws[S1i] Ws S1i S1i++ S1i {
				S2 += Ws[S2i];
				S2i--;
			} S2 += Ws[S2i] S2 Ws[S2i] Ws S2i S2i-- S2i int result; result if(S1 > S2) {
			result = S1 - S2;
		} else {
			result = S2 - S1;
		} S1 > S2 S1 S2 {
			result = S1 - S2;
		} result = S1 - S2 result S1 - S2 S1 S2 {
			result = S2 - S1;
		} result = S2 - S1 result S2 - S1 S2 S1 System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] Ws = new int[N];
		for(int i = 0; i < N; i++) {
			Ws[i] = sc.nextInt();
		}
		
		int S1 = 0;
		int S2 = 0;
		int S1i = 0;
		int S2i = N - 1;
		
		while(S1i <= S2i) {
			if(S1 < S2) {
				S1 += Ws[S1i];
				S1i++;
			} else {
				S2 += Ws[S2i];
				S2i--;
			}
		}
		
		int result;
		if(S1 > S2) {
			result = S1 - S2;
		} else {
			result = S2 - S1;
		}

		System.out.println(result);
	}
	
} public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] Ws = new int[N];
		for(int i = 0; i < N; i++) {
			Ws[i] = sc.nextInt();
		}
		
		int S1 = 0;
		int S2 = 0;
		int S1i = 0;
		int S2i = N - 1;
		
		while(S1i <= S2i) {
			if(S1 < S2) {
				S1 += Ws[S1i];
				S1i++;
			} else {
				S2 += Ws[S2i];
				S2i--;
			}
		}
		
		int result;
		if(S1 > S2) {
			result = S1 - S2;
		} else {
			result = S2 - S1;
		}

		System.out.println(result);
	}
	
} Main
import java.util.Scanner;

/**
 * 2019/06/09
 * AtCoder Beginner Contest 129
 * 
 * B - Balance
 * 
 * @author rued97
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] Ws = new int[N];
		for(int i = 0; i < N; i++) {
			Ws[i] = sc.nextInt();
		}
		
		int S1 = 0;
		int S2 = 0;
		int S1i = 0;
		int S2i = N - 1;
		
		while(S1i <= S2i) {
			if(S1 < S2) {
				S1 += Ws[S1i];
				S1i++;
			} else {
				S2 += Ws[S2i];
				S2i--;
			}
		}
		
		int result;
		if(S1 > S2) {
			result = S1 - S2;
		} else {
			result = S2 - S1;
		}

		System.out.println(result);
	}
	
}
