import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int[] w = new int[n];
		w[0] = sc.nextInt();
		for (int i = 1; i < n; i++) {
			w[i] = w[i - 1] + sc.nextInt();
		}
		int min = Integer.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			min = Math.min(min, Math.abs(w[i] - (w[n - 1] - w[i])));
		}
		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);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int[] w = new int[n];
		w[0] = sc.nextInt();
		for (int i = 1; i < n; i++) {
			w[i] = w[i - 1] + sc.nextInt();
		}
		int min = Integer.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			min = Math.min(min, Math.abs(w[i] - (w[n - 1] - w[i])));
		}
		System.out.println(min);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int[] w = new int[n];
		w[0] = sc.nextInt();
		for (int i = 1; i < n; i++) {
			w[i] = w[i - 1] + sc.nextInt();
		}
		int min = Integer.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			min = Math.min(min, Math.abs(w[i] - (w[n - 1] - w[i])));
		}
		System.out.println(min);
	} main {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int[] w = new int[n];
		w[0] = sc.nextInt();
		for (int i = 1; i < n; i++) {
			w[i] = w[i - 1] + sc.nextInt();
		}
		int min = Integer.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			min = Math.min(min, Math.abs(w[i] - (w[n - 1] - w[i])));
		}
		System.out.println(min);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) StringBuilder sb = new StringBuilder(); sb new StringBuilder() int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] w = new int[n]; w new int[n] n w[0] = sc.nextInt() w[0] w 0 sc.nextInt() sc.nextInt sc for (int i = 1; i < n; i++) {
			w[i] = w[i - 1] + sc.nextInt();
		} int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
			w[i] = w[i - 1] + sc.nextInt();
		} {
			w[i] = w[i - 1] + sc.nextInt();
		} w[i] = w[i - 1] + sc.nextInt() w[i] w i w[i - 1] + sc.nextInt() w[i - 1] w i - 1 i 1 sc.nextInt() sc.nextInt sc int min = Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int i = 0; i < n; i++) {
			min = Math.min(min, Math.abs(w[i] - (w[n - 1] - w[i])));
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			min = Math.min(min, Math.abs(w[i] - (w[n - 1] - w[i])));
		} {
			min = Math.min(min, Math.abs(w[i] - (w[n - 1] - w[i])));
		} min = Math.min(min, Math.abs(w[i] - (w[n - 1] - w[i]))) min Math.min(min, Math.abs(w[i] - (w[n - 1] - w[i]))) Math.min Math min Math.abs(w[i] - (w[n - 1] - w[i])) Math.abs Math w[i] - (w[n - 1] - w[i]) w[i] w i (w[n - 1] - w[i]) w[n - 1] w n - 1 n 1 w[i] w i 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);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int[] w = new int[n];
		w[0] = sc.nextInt();
		for (int i = 1; i < n; i++) {
			w[i] = w[i - 1] + sc.nextInt();
		}
		int min = Integer.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			min = Math.min(min, Math.abs(w[i] - (w[n - 1] - w[i])));
		}
		System.out.println(min);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int[] w = new int[n];
		w[0] = sc.nextInt();
		for (int i = 1; i < n; i++) {
			w[i] = w[i - 1] + sc.nextInt();
		}
		int min = Integer.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			min = Math.min(min, Math.abs(w[i] - (w[n - 1] - w[i])));
		}
		System.out.println(min);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int[] w = new int[n];
		w[0] = sc.nextInt();
		for (int i = 1; i < n; i++) {
			w[i] = w[i - 1] + sc.nextInt();
		}
		int min = Integer.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			min = Math.min(min, Math.abs(w[i] - (w[n - 1] - w[i])));
		}
		System.out.println(min);
	}
}
