import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int p[] = new int[N];
		int sum =0;
		for (int i=0;i<N;i++) {
			p[i] = sc.nextInt();
			sum +=p[i];
		}
		int front =0;
		int min = Integer.MAX_VALUE;
		for (int i=0;i<N;i++) {
			front +=p[i];
			if (min >Math.abs(sum-2*front)) {
				min = Math.abs(sum-2*front);
			}
		}
		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 p[] = new int[N];
		int sum =0;
		for (int i=0;i<N;i++) {
			p[i] = sc.nextInt();
			sum +=p[i];
		}
		int front =0;
		int min = Integer.MAX_VALUE;
		for (int i=0;i<N;i++) {
			front +=p[i];
			if (min >Math.abs(sum-2*front)) {
				min = Math.abs(sum-2*front);
			}
		}
		System.out.println(min);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int p[] = new int[N];
		int sum =0;
		for (int i=0;i<N;i++) {
			p[i] = sc.nextInt();
			sum +=p[i];
		}
		int front =0;
		int min = Integer.MAX_VALUE;
		for (int i=0;i<N;i++) {
			front +=p[i];
			if (min >Math.abs(sum-2*front)) {
				min = Math.abs(sum-2*front);
			}
		}
		System.out.println(min);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int p[] = new int[N];
		int sum =0;
		for (int i=0;i<N;i++) {
			p[i] = sc.nextInt();
			sum +=p[i];
		}
		int front =0;
		int min = Integer.MAX_VALUE;
		for (int i=0;i<N;i++) {
			front +=p[i];
			if (min >Math.abs(sum-2*front)) {
				min = Math.abs(sum-2*front);
			}
		}
		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 p[] = new int[N]; p new int[N] N int sum =0; sum 0 for (int i=0;i<N;i++) {
			p[i] = sc.nextInt();
			sum +=p[i];
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			p[i] = sc.nextInt();
			sum +=p[i];
		} {
			p[i] = sc.nextInt();
			sum +=p[i];
		} p[i] = sc.nextInt() p[i] p i sc.nextInt() sc.nextInt sc sum +=p[i] sum p[i] p i int front =0; front 0 int min = Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int i=0;i<N;i++) {
			front +=p[i];
			if (min >Math.abs(sum-2*front)) {
				min = Math.abs(sum-2*front);
			}
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			front +=p[i];
			if (min >Math.abs(sum-2*front)) {
				min = Math.abs(sum-2*front);
			}
		} {
			front +=p[i];
			if (min >Math.abs(sum-2*front)) {
				min = Math.abs(sum-2*front);
			}
		} front +=p[i] front p[i] p i if (min >Math.abs(sum-2*front)) {
				min = Math.abs(sum-2*front);
			} min >Math.abs(sum-2*front) min Math.abs(sum-2*front) Math.abs Math sum-2*front sum 2*front 2 front {
				min = Math.abs(sum-2*front);
			} min = Math.abs(sum-2*front) min Math.abs(sum-2*front) Math.abs Math sum-2*front sum 2*front 2 front 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 p[] = new int[N];
		int sum =0;
		for (int i=0;i<N;i++) {
			p[i] = sc.nextInt();
			sum +=p[i];
		}
		int front =0;
		int min = Integer.MAX_VALUE;
		for (int i=0;i<N;i++) {
			front +=p[i];
			if (min >Math.abs(sum-2*front)) {
				min = Math.abs(sum-2*front);
			}
		}
		System.out.println(min);
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int p[] = new int[N];
		int sum =0;
		for (int i=0;i<N;i++) {
			p[i] = sc.nextInt();
			sum +=p[i];
		}
		int front =0;
		int min = Integer.MAX_VALUE;
		for (int i=0;i<N;i++) {
			front +=p[i];
			if (min >Math.abs(sum-2*front)) {
				min = Math.abs(sum-2*front);
			}
		}
		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 p[] = new int[N];
		int sum =0;
		for (int i=0;i<N;i++) {
			p[i] = sc.nextInt();
			sum +=p[i];
		}
		int front =0;
		int min = Integer.MAX_VALUE;
		for (int i=0;i<N;i++) {
			front +=p[i];
			if (min >Math.abs(sum-2*front)) {
				min = Math.abs(sum-2*front);
			}
		}
		System.out.println(min);
	}
}
