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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int wsum[] = new int[n];
		wsum[0] = sc.nextInt();
		for(int i=1;i<n;i++) {
			wsum[i] = wsum[i-1]+sc.nextInt();
		}
		
		int sum = wsum[n-1];
		int min = sum;
		
		for(int i=0;i<n-1;i++) {
			if(min > zettaichi(sum - 2 * wsum[i]))
				min = zettaichi(sum - 2 * wsum[i]);
			else
				break;
		}
		
		System.out.print(min);
	}
	public static int zettaichi(int a) {
		if(a>=0)
			return a;
		else
			return -a;
	}
	
} import java.util.Arrays; Arrays java.util 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 wsum[] = new int[n];
		wsum[0] = sc.nextInt();
		for(int i=1;i<n;i++) {
			wsum[i] = wsum[i-1]+sc.nextInt();
		}
		
		int sum = wsum[n-1];
		int min = sum;
		
		for(int i=0;i<n-1;i++) {
			if(min > zettaichi(sum - 2 * wsum[i]))
				min = zettaichi(sum - 2 * wsum[i]);
			else
				break;
		}
		
		System.out.print(min);
	}
	public static int zettaichi(int a) {
		if(a>=0)
			return a;
		else
			return -a;
	}
	
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int wsum[] = new int[n];
		wsum[0] = sc.nextInt();
		for(int i=1;i<n;i++) {
			wsum[i] = wsum[i-1]+sc.nextInt();
		}
		
		int sum = wsum[n-1];
		int min = sum;
		
		for(int i=0;i<n-1;i++) {
			if(min > zettaichi(sum - 2 * wsum[i]))
				min = zettaichi(sum - 2 * wsum[i]);
			else
				break;
		}
		
		System.out.print(min);
	} main {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int wsum[] = new int[n];
		wsum[0] = sc.nextInt();
		for(int i=1;i<n;i++) {
			wsum[i] = wsum[i-1]+sc.nextInt();
		}
		
		int sum = wsum[n-1];
		int min = sum;
		
		for(int i=0;i<n-1;i++) {
			if(min > zettaichi(sum - 2 * wsum[i]))
				min = zettaichi(sum - 2 * wsum[i]);
			else
				break;
		}
		
		System.out.print(min);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n=sc.nextInt(); n sc.nextInt() sc.nextInt sc int wsum[] = new int[n]; wsum new int[n] n wsum[0] = sc.nextInt() wsum[0] wsum 0 sc.nextInt() sc.nextInt sc for(int i=1;i<n;i++) {
			wsum[i] = wsum[i-1]+sc.nextInt();
		} int i=1; int i=1; i 1 i<n i n i++ i++ i {
			wsum[i] = wsum[i-1]+sc.nextInt();
		} {
			wsum[i] = wsum[i-1]+sc.nextInt();
		} wsum[i] = wsum[i-1]+sc.nextInt() wsum[i] wsum i wsum[i-1]+sc.nextInt() wsum[i-1] wsum i-1 i 1 sc.nextInt() sc.nextInt sc int sum = wsum[n-1]; sum wsum[n-1] wsum n-1 n 1 int min = sum; min sum for(int i=0;i<n-1;i++) {
			if(min > zettaichi(sum - 2 * wsum[i]))
				min = zettaichi(sum - 2 * wsum[i]);
			else
				break;
		} int i=0; int i=0; i 0 i<n-1 i n-1 n 1 i++ i++ i {
			if(min > zettaichi(sum - 2 * wsum[i]))
				min = zettaichi(sum - 2 * wsum[i]);
			else
				break;
		} {
			if(min > zettaichi(sum - 2 * wsum[i]))
				min = zettaichi(sum - 2 * wsum[i]);
			else
				break;
		} if(min > zettaichi(sum - 2 * wsum[i]))
				min = zettaichi(sum - 2 * wsum[i]);
			else
				break; min > zettaichi(sum - 2 * wsum[i]) min zettaichi(sum - 2 * wsum[i]) zettaichi sum - 2 * wsum[i] sum 2 * wsum[i] 2 wsum[i] wsum i min = zettaichi(sum - 2 * wsum[i]) min zettaichi(sum - 2 * wsum[i]) zettaichi sum - 2 * wsum[i] sum 2 * wsum[i] 2 wsum[i] wsum i break; System.out.print(min) System.out.print System.out System System.out min String[] args args public static int zettaichi(int a) {
		if(a>=0)
			return a;
		else
			return -a;
	} zettaichi {
		if(a>=0)
			return a;
		else
			return -a;
	} if(a>=0)
			return a;
		else
			return -a; a>=0 a 0 return a; a return -a; -a a int a a public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int wsum[] = new int[n];
		wsum[0] = sc.nextInt();
		for(int i=1;i<n;i++) {
			wsum[i] = wsum[i-1]+sc.nextInt();
		}
		
		int sum = wsum[n-1];
		int min = sum;
		
		for(int i=0;i<n-1;i++) {
			if(min > zettaichi(sum - 2 * wsum[i]))
				min = zettaichi(sum - 2 * wsum[i]);
			else
				break;
		}
		
		System.out.print(min);
	}
	public static int zettaichi(int a) {
		if(a>=0)
			return a;
		else
			return -a;
	}
	
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int wsum[] = new int[n];
		wsum[0] = sc.nextInt();
		for(int i=1;i<n;i++) {
			wsum[i] = wsum[i-1]+sc.nextInt();
		}
		
		int sum = wsum[n-1];
		int min = sum;
		
		for(int i=0;i<n-1;i++) {
			if(min > zettaichi(sum - 2 * wsum[i]))
				min = zettaichi(sum - 2 * wsum[i]);
			else
				break;
		}
		
		System.out.print(min);
	}
	public static int zettaichi(int a) {
		if(a>=0)
			return a;
		else
			return -a;
	}
	
} Main
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int wsum[] = new int[n];
		wsum[0] = sc.nextInt();
		for(int i=1;i<n;i++) {
			wsum[i] = wsum[i-1]+sc.nextInt();
		}
		
		int sum = wsum[n-1];
		int min = sum;
		
		for(int i=0;i<n-1;i++) {
			if(min > zettaichi(sum - 2 * wsum[i]))
				min = zettaichi(sum - 2 * wsum[i]);
			else
				break;
		}
		
		System.out.print(min);
	}
	public static int zettaichi(int a) {
		if(a>=0)
			return a;
		else
			return -a;
	}
	
}