import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.nextLine());
		String s = sc.nextLine();
		sc.close();

		String[] spl = s.split(" ");
		int[] Wi = new int[spl.length];
		int sum1 = 0;
		int sum2 = 0;

		for(int i = 0;i < Wi.length;i++){
			Wi[i] = Integer.parseInt(spl[i]);
			sum1 += Wi[i];
		}

		int abs = sum1;

		for(int i = 0;i < Wi.length;i++){
			sum1 -= Wi[i];
			sum2 += Wi[i];
			if(abs > Math.abs(sum1 - sum2)){
				abs = Math.abs(sum1 - sum2);
			}
		}
		System.out.println(abs);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.nextLine());
		String s = sc.nextLine();
		sc.close();

		String[] spl = s.split(" ");
		int[] Wi = new int[spl.length];
		int sum1 = 0;
		int sum2 = 0;

		for(int i = 0;i < Wi.length;i++){
			Wi[i] = Integer.parseInt(spl[i]);
			sum1 += Wi[i];
		}

		int abs = sum1;

		for(int i = 0;i < Wi.length;i++){
			sum1 -= Wi[i];
			sum2 += Wi[i];
			if(abs > Math.abs(sum1 - sum2)){
				abs = Math.abs(sum1 - sum2);
			}
		}
		System.out.println(abs);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.nextLine());
		String s = sc.nextLine();
		sc.close();

		String[] spl = s.split(" ");
		int[] Wi = new int[spl.length];
		int sum1 = 0;
		int sum2 = 0;

		for(int i = 0;i < Wi.length;i++){
			Wi[i] = Integer.parseInt(spl[i]);
			sum1 += Wi[i];
		}

		int abs = sum1;

		for(int i = 0;i < Wi.length;i++){
			sum1 -= Wi[i];
			sum2 += Wi[i];
			if(abs > Math.abs(sum1 - sum2)){
				abs = Math.abs(sum1 - sum2);
			}
		}
		System.out.println(abs);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.nextLine());
		String s = sc.nextLine();
		sc.close();

		String[] spl = s.split(" ");
		int[] Wi = new int[spl.length];
		int sum1 = 0;
		int sum2 = 0;

		for(int i = 0;i < Wi.length;i++){
			Wi[i] = Integer.parseInt(spl[i]);
			sum1 += Wi[i];
		}

		int abs = sum1;

		for(int i = 0;i < Wi.length;i++){
			sum1 -= Wi[i];
			sum2 += Wi[i];
			if(abs > Math.abs(sum1 - sum2)){
				abs = Math.abs(sum1 - sum2);
			}
		}
		System.out.println(abs);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = Integer.parseInt(sc.nextLine()); N Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc String s = sc.nextLine(); s sc.nextLine() sc.nextLine sc sc.close() sc.close sc String[] spl = s.split(" "); spl s.split(" ") s.split s " " int[] Wi = new int[spl.length]; Wi new int[spl.length] spl.length spl spl.length int sum1 = 0; sum1 0 int sum2 = 0; sum2 0 for(int i = 0;i < Wi.length;i++){
			Wi[i] = Integer.parseInt(spl[i]);
			sum1 += Wi[i];
		} int i = 0; int i = 0; i 0 i < Wi.length i Wi.length Wi Wi.length i++ i++ i {
			Wi[i] = Integer.parseInt(spl[i]);
			sum1 += Wi[i];
		} {
			Wi[i] = Integer.parseInt(spl[i]);
			sum1 += Wi[i];
		} Wi[i] = Integer.parseInt(spl[i]) Wi[i] Wi i Integer.parseInt(spl[i]) Integer.parseInt Integer spl[i] spl i sum1 += Wi[i] sum1 Wi[i] Wi i int abs = sum1; abs sum1 for(int i = 0;i < Wi.length;i++){
			sum1 -= Wi[i];
			sum2 += Wi[i];
			if(abs > Math.abs(sum1 - sum2)){
				abs = Math.abs(sum1 - sum2);
			}
		} int i = 0; int i = 0; i 0 i < Wi.length i Wi.length Wi Wi.length i++ i++ i {
			sum1 -= Wi[i];
			sum2 += Wi[i];
			if(abs > Math.abs(sum1 - sum2)){
				abs = Math.abs(sum1 - sum2);
			}
		} {
			sum1 -= Wi[i];
			sum2 += Wi[i];
			if(abs > Math.abs(sum1 - sum2)){
				abs = Math.abs(sum1 - sum2);
			}
		} sum1 -= Wi[i] sum1 Wi[i] Wi i sum2 += Wi[i] sum2 Wi[i] Wi i if(abs > Math.abs(sum1 - sum2)){
				abs = Math.abs(sum1 - sum2);
			} abs > Math.abs(sum1 - sum2) abs Math.abs(sum1 - sum2) Math.abs Math sum1 - sum2 sum1 sum2 {
				abs = Math.abs(sum1 - sum2);
			} abs = Math.abs(sum1 - sum2) abs Math.abs(sum1 - sum2) Math.abs Math sum1 - sum2 sum1 sum2 System.out.println(abs) System.out.println System.out System System.out abs String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.nextLine());
		String s = sc.nextLine();
		sc.close();

		String[] spl = s.split(" ");
		int[] Wi = new int[spl.length];
		int sum1 = 0;
		int sum2 = 0;

		for(int i = 0;i < Wi.length;i++){
			Wi[i] = Integer.parseInt(spl[i]);
			sum1 += Wi[i];
		}

		int abs = sum1;

		for(int i = 0;i < Wi.length;i++){
			sum1 -= Wi[i];
			sum2 += Wi[i];
			if(abs > Math.abs(sum1 - sum2)){
				abs = Math.abs(sum1 - sum2);
			}
		}
		System.out.println(abs);
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.nextLine());
		String s = sc.nextLine();
		sc.close();

		String[] spl = s.split(" ");
		int[] Wi = new int[spl.length];
		int sum1 = 0;
		int sum2 = 0;

		for(int i = 0;i < Wi.length;i++){
			Wi[i] = Integer.parseInt(spl[i]);
			sum1 += Wi[i];
		}

		int abs = sum1;

		for(int i = 0;i < Wi.length;i++){
			sum1 -= Wi[i];
			sum2 += Wi[i];
			if(abs > Math.abs(sum1 - sum2)){
				abs = Math.abs(sum1 - sum2);
			}
		}
		System.out.println(abs);
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.nextLine());
		String s = sc.nextLine();
		sc.close();

		String[] spl = s.split(" ");
		int[] Wi = new int[spl.length];
		int sum1 = 0;
		int sum2 = 0;

		for(int i = 0;i < Wi.length;i++){
			Wi[i] = Integer.parseInt(spl[i]);
			sum1 += Wi[i];
		}

		int abs = sum1;

		for(int i = 0;i < Wi.length;i++){
			sum1 -= Wi[i];
			sum2 += Wi[i];
			if(abs > Math.abs(sum1 - sum2)){
				abs = Math.abs(sum1 - sum2);
			}
		}
		System.out.println(abs);
	}
}