import java.util.Scanner;

public class Main {
	int n;
	Integer w[];

	public Main(int n, Integer w[]) {
		this.n = n;
		this.w = w;
	}

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		Integer w[] = new Integer[n];
		for (int i = 0; i < n; i++) {
			w[i] = s.nextInt();
		}
		System.out.println(new Main(n, w).calc());
	}

	public int calc() {
		int res = Integer.MAX_VALUE;
		for (int ti = 0; ti < w.length; ti++) {
			int s1 = 0;
			int s2 = 0;
			for (int i = 0; i <= ti; i++) {
				s1 += w[i];
			}
			for (int i = w.length - 1; ti < i; i--) {
				s2 += w[i];
			}
			res = Math.min(Math.abs(s1 - s2), res);
		}
		return res;
	}
} import java.util.Scanner; Scanner java.util public class Main {
	int n;
	Integer w[];

	public Main(int n, Integer w[]) {
		this.n = n;
		this.w = w;
	}

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		Integer w[] = new Integer[n];
		for (int i = 0; i < n; i++) {
			w[i] = s.nextInt();
		}
		System.out.println(new Main(n, w).calc());
	}

	public int calc() {
		int res = Integer.MAX_VALUE;
		for (int ti = 0; ti < w.length; ti++) {
			int s1 = 0;
			int s2 = 0;
			for (int i = 0; i <= ti; i++) {
				s1 += w[i];
			}
			for (int i = w.length - 1; ti < i; i--) {
				s2 += w[i];
			}
			res = Math.min(Math.abs(s1 - s2), res);
		}
		return res;
	}
} Main int n; n Integer w[]; w public Main(int n, Integer w[]) {
		this.n = n;
		this.w = w;
	} Main {
		this.n = n;
		this.w = w;
	} this.n = n this.n this this.n n this.w = w this.w this this.w w int n n Integer w[] w public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		Integer w[] = new Integer[n];
		for (int i = 0; i < n; i++) {
			w[i] = s.nextInt();
		}
		System.out.println(new Main(n, w).calc());
	} main {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		Integer w[] = new Integer[n];
		for (int i = 0; i < n; i++) {
			w[i] = s.nextInt();
		}
		System.out.println(new Main(n, w).calc());
	} Scanner s = new Scanner(System.in); s new Scanner(System.in) int n = s.nextInt(); n s.nextInt() s.nextInt s Integer w[] = new Integer[n]; w new Integer[n] n for (int i = 0; i < n; i++) {
			w[i] = s.nextInt();
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			w[i] = s.nextInt();
		} {
			w[i] = s.nextInt();
		} w[i] = s.nextInt() w[i] w i s.nextInt() s.nextInt s System.out.println(new Main(n, w).calc()) System.out.println System.out System System.out new Main(n, w).calc() new Main(n, w).calc new Main(n, w) String[] args args public int calc() {
		int res = Integer.MAX_VALUE;
		for (int ti = 0; ti < w.length; ti++) {
			int s1 = 0;
			int s2 = 0;
			for (int i = 0; i <= ti; i++) {
				s1 += w[i];
			}
			for (int i = w.length - 1; ti < i; i--) {
				s2 += w[i];
			}
			res = Math.min(Math.abs(s1 - s2), res);
		}
		return res;
	} calc {
		int res = Integer.MAX_VALUE;
		for (int ti = 0; ti < w.length; ti++) {
			int s1 = 0;
			int s2 = 0;
			for (int i = 0; i <= ti; i++) {
				s1 += w[i];
			}
			for (int i = w.length - 1; ti < i; i--) {
				s2 += w[i];
			}
			res = Math.min(Math.abs(s1 - s2), res);
		}
		return res;
	} int res = Integer.MAX_VALUE; res Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int ti = 0; ti < w.length; ti++) {
			int s1 = 0;
			int s2 = 0;
			for (int i = 0; i <= ti; i++) {
				s1 += w[i];
			}
			for (int i = w.length - 1; ti < i; i--) {
				s2 += w[i];
			}
			res = Math.min(Math.abs(s1 - s2), res);
		} int ti = 0; int ti = 0; ti 0 ti < w.length ti w.length w w.length ti++ ti++ ti {
			int s1 = 0;
			int s2 = 0;
			for (int i = 0; i <= ti; i++) {
				s1 += w[i];
			}
			for (int i = w.length - 1; ti < i; i--) {
				s2 += w[i];
			}
			res = Math.min(Math.abs(s1 - s2), res);
		} {
			int s1 = 0;
			int s2 = 0;
			for (int i = 0; i <= ti; i++) {
				s1 += w[i];
			}
			for (int i = w.length - 1; ti < i; i--) {
				s2 += w[i];
			}
			res = Math.min(Math.abs(s1 - s2), res);
		} int s1 = 0; s1 0 int s2 = 0; s2 0 for (int i = 0; i <= ti; i++) {
				s1 += w[i];
			} int i = 0; int i = 0; i 0 i <= ti i ti i++ i++ i {
				s1 += w[i];
			} {
				s1 += w[i];
			} s1 += w[i] s1 w[i] w i for (int i = w.length - 1; ti < i; i--) {
				s2 += w[i];
			} int i = w.length - 1; int i = w.length - 1; i w.length - 1 w.length w w.length 1 ti < i ti i i-- i-- i {
				s2 += w[i];
			} {
				s2 += w[i];
			} s2 += w[i] s2 w[i] w i res = Math.min(Math.abs(s1 - s2), res) res Math.min(Math.abs(s1 - s2), res) Math.min Math Math.abs(s1 - s2) Math.abs Math s1 - s2 s1 s2 res return res; res public class Main {
	int n;
	Integer w[];

	public Main(int n, Integer w[]) {
		this.n = n;
		this.w = w;
	}

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		Integer w[] = new Integer[n];
		for (int i = 0; i < n; i++) {
			w[i] = s.nextInt();
		}
		System.out.println(new Main(n, w).calc());
	}

	public int calc() {
		int res = Integer.MAX_VALUE;
		for (int ti = 0; ti < w.length; ti++) {
			int s1 = 0;
			int s2 = 0;
			for (int i = 0; i <= ti; i++) {
				s1 += w[i];
			}
			for (int i = w.length - 1; ti < i; i--) {
				s2 += w[i];
			}
			res = Math.min(Math.abs(s1 - s2), res);
		}
		return res;
	}
} public class Main {
	int n;
	Integer w[];

	public Main(int n, Integer w[]) {
		this.n = n;
		this.w = w;
	}

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		Integer w[] = new Integer[n];
		for (int i = 0; i < n; i++) {
			w[i] = s.nextInt();
		}
		System.out.println(new Main(n, w).calc());
	}

	public int calc() {
		int res = Integer.MAX_VALUE;
		for (int ti = 0; ti < w.length; ti++) {
			int s1 = 0;
			int s2 = 0;
			for (int i = 0; i <= ti; i++) {
				s1 += w[i];
			}
			for (int i = w.length - 1; ti < i; i--) {
				s2 += w[i];
			}
			res = Math.min(Math.abs(s1 - s2), res);
		}
		return res;
	}
} Main
import java.util.Scanner;

public class Main {
	int n;
	Integer w[];

	public Main(int n, Integer w[]) {
		this.n = n;
		this.w = w;
	}

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		Integer w[] = new Integer[n];
		for (int i = 0; i < n; i++) {
			w[i] = s.nextInt();
		}
		System.out.println(new Main(n, w).calc());
	}

	public int calc() {
		int res = Integer.MAX_VALUE;
		for (int ti = 0; ti < w.length; ti++) {
			int s1 = 0;
			int s2 = 0;
			for (int i = 0; i <= ti; i++) {
				s1 += w[i];
			}
			for (int i = w.length - 1; ti < i; i--) {
				s2 += w[i];
			}
			res = Math.min(Math.abs(s1 - s2), res);
		}
		return res;
	}
}