import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int w[] = new int[n];
			int s1 = 0;
			int s2 = 0;
			for (int i = 0; i < n; i++) {
				w[i] = sc.nextInt();
				s2 += w[i];
			}

			int ans = s2;
			int dif = 0;
			for (int i = 0; i < n; i++) {
				s1 += w[i];
				s2 -= w[i];
				dif = Math.abs(s1 - s2);
				if (dif < ans) {
					ans = dif;
				}
			}
			
			System.out.println(ans);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int w[] = new int[n];
			int s1 = 0;
			int s2 = 0;
			for (int i = 0; i < n; i++) {
				w[i] = sc.nextInt();
				s2 += w[i];
			}

			int ans = s2;
			int dif = 0;
			for (int i = 0; i < n; i++) {
				s1 += w[i];
				s2 -= w[i];
				dif = Math.abs(s1 - s2);
				if (dif < ans) {
					ans = dif;
				}
			}
			
			System.out.println(ans);
		}
	}
} Main public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int w[] = new int[n];
			int s1 = 0;
			int s2 = 0;
			for (int i = 0; i < n; i++) {
				w[i] = sc.nextInt();
				s2 += w[i];
			}

			int ans = s2;
			int dif = 0;
			for (int i = 0; i < n; i++) {
				s1 += w[i];
				s2 -= w[i];
				dif = Math.abs(s1 - s2);
				if (dif < ans) {
					ans = dif;
				}
			}
			
			System.out.println(ans);
		}
	} main {

		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int w[] = new int[n];
			int s1 = 0;
			int s2 = 0;
			for (int i = 0; i < n; i++) {
				w[i] = sc.nextInt();
				s2 += w[i];
			}

			int ans = s2;
			int dif = 0;
			for (int i = 0; i < n; i++) {
				s1 += w[i];
				s2 -= w[i];
				dif = Math.abs(s1 - s2);
				if (dif < ans) {
					ans = dif;
				}
			}
			
			System.out.println(ans);
		}
	} try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int w[] = new int[n];
			int s1 = 0;
			int s2 = 0;
			for (int i = 0; i < n; i++) {
				w[i] = sc.nextInt();
				s2 += w[i];
			}

			int ans = s2;
			int dif = 0;
			for (int i = 0; i < n; i++) {
				s1 += w[i];
				s2 -= w[i];
				dif = Math.abs(s1 - s2);
				if (dif < ans) {
					ans = dif;
				}
			}
			
			System.out.println(ans);
		} {
			int n = sc.nextInt();
			int w[] = new int[n];
			int s1 = 0;
			int s2 = 0;
			for (int i = 0; i < n; i++) {
				w[i] = sc.nextInt();
				s2 += w[i];
			}

			int ans = s2;
			int dif = 0;
			for (int i = 0; i < n; i++) {
				s1 += w[i];
				s2 -= w[i];
				dif = Math.abs(s1 - s2);
				if (dif < ans) {
					ans = dif;
				}
			}
			
			System.out.println(ans);
		} Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int w[] = new int[n]; w new int[n] n int s1 = 0; s1 0 int s2 = 0; s2 0 for (int i = 0; i < n; i++) {
				w[i] = sc.nextInt();
				s2 += w[i];
			} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
				w[i] = sc.nextInt();
				s2 += w[i];
			} {
				w[i] = sc.nextInt();
				s2 += w[i];
			} w[i] = sc.nextInt() w[i] w i sc.nextInt() sc.nextInt sc s2 += w[i] s2 w[i] w i int ans = s2; ans s2 int dif = 0; dif 0 for (int i = 0; i < n; i++) {
				s1 += w[i];
				s2 -= w[i];
				dif = Math.abs(s1 - s2);
				if (dif < ans) {
					ans = dif;
				}
			} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
				s1 += w[i];
				s2 -= w[i];
				dif = Math.abs(s1 - s2);
				if (dif < ans) {
					ans = dif;
				}
			} {
				s1 += w[i];
				s2 -= w[i];
				dif = Math.abs(s1 - s2);
				if (dif < ans) {
					ans = dif;
				}
			} s1 += w[i] s1 w[i] w i s2 -= w[i] s2 w[i] w i dif = Math.abs(s1 - s2) dif Math.abs(s1 - s2) Math.abs Math s1 - s2 s1 s2 if (dif < ans) {
					ans = dif;
				} dif < ans dif ans {
					ans = dif;
				} ans = dif ans dif System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int w[] = new int[n];
			int s1 = 0;
			int s2 = 0;
			for (int i = 0; i < n; i++) {
				w[i] = sc.nextInt();
				s2 += w[i];
			}

			int ans = s2;
			int dif = 0;
			for (int i = 0; i < n; i++) {
				s1 += w[i];
				s2 -= w[i];
				dif = Math.abs(s1 - s2);
				if (dif < ans) {
					ans = dif;
				}
			}
			
			System.out.println(ans);
		}
	}
} public class Main {

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int w[] = new int[n];
			int s1 = 0;
			int s2 = 0;
			for (int i = 0; i < n; i++) {
				w[i] = sc.nextInt();
				s2 += w[i];
			}

			int ans = s2;
			int dif = 0;
			for (int i = 0; i < n; i++) {
				s1 += w[i];
				s2 -= w[i];
				dif = Math.abs(s1 - s2);
				if (dif < ans) {
					ans = dif;
				}
			}
			
			System.out.println(ans);
		}
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int w[] = new int[n];
			int s1 = 0;
			int s2 = 0;
			for (int i = 0; i < n; i++) {
				w[i] = sc.nextInt();
				s2 += w[i];
			}

			int ans = s2;
			int dif = 0;
			for (int i = 0; i < n; i++) {
				s1 += w[i];
				s2 -= w[i];
				dif = Math.abs(s1 - s2);
				if (dif < ans) {
					ans = dif;
				}
			}
			
			System.out.println(ans);
		}
	}
}
