import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] w = new int[n];
		for(int i = 0 ; i < n ; i++) {
			w[i] = sc.nextInt();
		}
		int ans = Integer.MAX_VALUE;
		for(int i = 1 ; i < n ; i++) {
			int s1 = 0;
			int s2 = 0;
			for(int j = 0 ; j < i ; j++) {
				s1 += w[j];
			}
			for(int j = i ; j < n ; j++) {
				s2 += w[j];
			}
			ans = Math.min(ans, Math.abs(s2 - s1));
		}
		System.out.println(ans);
		sc.close();

	}

} 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[] w = new int[n];
		for(int i = 0 ; i < n ; i++) {
			w[i] = sc.nextInt();
		}
		int ans = Integer.MAX_VALUE;
		for(int i = 1 ; i < n ; i++) {
			int s1 = 0;
			int s2 = 0;
			for(int j = 0 ; j < i ; j++) {
				s1 += w[j];
			}
			for(int j = i ; j < n ; j++) {
				s2 += w[j];
			}
			ans = Math.min(ans, Math.abs(s2 - s1));
		}
		System.out.println(ans);
		sc.close();

	}

} Main public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] w = new int[n];
		for(int i = 0 ; i < n ; i++) {
			w[i] = sc.nextInt();
		}
		int ans = Integer.MAX_VALUE;
		for(int i = 1 ; i < n ; i++) {
			int s1 = 0;
			int s2 = 0;
			for(int j = 0 ; j < i ; j++) {
				s1 += w[j];
			}
			for(int j = i ; j < n ; j++) {
				s2 += w[j];
			}
			ans = Math.min(ans, Math.abs(s2 - s1));
		}
		System.out.println(ans);
		sc.close();

	} main {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] w = new int[n];
		for(int i = 0 ; i < n ; i++) {
			w[i] = sc.nextInt();
		}
		int ans = Integer.MAX_VALUE;
		for(int i = 1 ; i < n ; i++) {
			int s1 = 0;
			int s2 = 0;
			for(int j = 0 ; j < i ; j++) {
				s1 += w[j];
			}
			for(int j = i ; j < n ; j++) {
				s2 += w[j];
			}
			ans = Math.min(ans, Math.abs(s2 - s1));
		}
		System.out.println(ans);
		sc.close();

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

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] w = new int[n];
		for(int i = 0 ; i < n ; i++) {
			w[i] = sc.nextInt();
		}
		int ans = Integer.MAX_VALUE;
		for(int i = 1 ; i < n ; i++) {
			int s1 = 0;
			int s2 = 0;
			for(int j = 0 ; j < i ; j++) {
				s1 += w[j];
			}
			for(int j = i ; j < n ; j++) {
				s2 += w[j];
			}
			ans = Math.min(ans, Math.abs(s2 - s1));
		}
		System.out.println(ans);
		sc.close();

	}

} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] w = new int[n];
		for(int i = 0 ; i < n ; i++) {
			w[i] = sc.nextInt();
		}
		int ans = Integer.MAX_VALUE;
		for(int i = 1 ; i < n ; i++) {
			int s1 = 0;
			int s2 = 0;
			for(int j = 0 ; j < i ; j++) {
				s1 += w[j];
			}
			for(int j = i ; j < n ; j++) {
				s2 += w[j];
			}
			ans = Math.min(ans, Math.abs(s2 - s1));
		}
		System.out.println(ans);
		sc.close();

	}

} 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[] w = new int[n];
		for(int i = 0 ; i < n ; i++) {
			w[i] = sc.nextInt();
		}
		int ans = Integer.MAX_VALUE;
		for(int i = 1 ; i < n ; i++) {
			int s1 = 0;
			int s2 = 0;
			for(int j = 0 ; j < i ; j++) {
				s1 += w[j];
			}
			for(int j = i ; j < n ; j++) {
				s2 += w[j];
			}
			ans = Math.min(ans, Math.abs(s2 - s1));
		}
		System.out.println(ans);
		sc.close();

	}

}
