import 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];
        int sum = 0;
		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
            sum+=W[i];
		}
        int ans = 0;
        int min = 0;
        boolean first = true;
		for (int i = 0; i < N; i++) {
        int s1 = 0;
		for (int j = 0; j <= i; j++) {
			s1+=W[j];
		}
        int s2 = sum - s1;
        int sa = Math.abs(s1-s2);
        if(first || min > sa){
          min = sa;
        }
        if(first){
          first = false;
        }
		}
		System.out.println(min);
	}		
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int N = sc.nextInt();
		int[] W = new int[N];
        int sum = 0;
		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
            sum+=W[i];
		}
        int ans = 0;
        int min = 0;
        boolean first = true;
		for (int i = 0; i < N; i++) {
        int s1 = 0;
		for (int j = 0; j <= i; j++) {
			s1+=W[j];
		}
        int s2 = sum - s1;
        int sa = Math.abs(s1-s2);
        if(first || min > sa){
          min = sa;
        }
        if(first){
          first = false;
        }
		}
		System.out.println(min);
	}		
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int N = sc.nextInt();
		int[] W = new int[N];
        int sum = 0;
		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
            sum+=W[i];
		}
        int ans = 0;
        int min = 0;
        boolean first = true;
		for (int i = 0; i < N; i++) {
        int s1 = 0;
		for (int j = 0; j <= i; j++) {
			s1+=W[j];
		}
        int s2 = sum - s1;
        int sa = Math.abs(s1-s2);
        if(first || min > sa){
          min = sa;
        }
        if(first){
          first = false;
        }
		}
		System.out.println(min);
	} main {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int N = sc.nextInt();
		int[] W = new int[N];
        int sum = 0;
		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
            sum+=W[i];
		}
        int ans = 0;
        int min = 0;
        boolean first = true;
		for (int i = 0; i < N; i++) {
        int s1 = 0;
		for (int j = 0; j <= i; j++) {
			s1+=W[j];
		}
        int s2 = sum - s1;
        int sa = Math.abs(s1-s2);
        if(first || min > sa){
          min = sa;
        }
        if(first){
          first = false;
        }
		}
		System.out.println(min);
	} 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 int sum = 0; sum 0 for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
            sum+=W[i];
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			W[i] = sc.nextInt();
            sum+=W[i];
		} {
			W[i] = sc.nextInt();
            sum+=W[i];
		} W[i] = sc.nextInt() W[i] W i sc.nextInt() sc.nextInt sc sum+=W[i] sum W[i] W i int ans = 0; ans 0 int min = 0; min 0 boolean first = true; first true for (int i = 0; i < N; i++) {
        int s1 = 0;
		for (int j = 0; j <= i; j++) {
			s1+=W[j];
		}
        int s2 = sum - s1;
        int sa = Math.abs(s1-s2);
        if(first || min > sa){
          min = sa;
        }
        if(first){
          first = false;
        }
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
        int s1 = 0;
		for (int j = 0; j <= i; j++) {
			s1+=W[j];
		}
        int s2 = sum - s1;
        int sa = Math.abs(s1-s2);
        if(first || min > sa){
          min = sa;
        }
        if(first){
          first = false;
        }
		} {
        int s1 = 0;
		for (int j = 0; j <= i; j++) {
			s1+=W[j];
		}
        int s2 = sum - s1;
        int sa = Math.abs(s1-s2);
        if(first || min > sa){
          min = sa;
        }
        if(first){
          first = false;
        }
		} int s1 = 0; s1 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 int s2 = sum - s1; s2 sum - s1 sum s1 int sa = Math.abs(s1-s2); sa Math.abs(s1-s2) Math.abs Math s1-s2 s1 s2 if(first || min > sa){
          min = sa;
        } first || min > sa first min > sa min sa {
          min = sa;
        } min = sa min sa if(first){
          first = false;
        } first {
          first = false;
        } first = false first false 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);
		
		// 入力
		int N = sc.nextInt();
		int[] W = new int[N];
        int sum = 0;
		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
            sum+=W[i];
		}
        int ans = 0;
        int min = 0;
        boolean first = true;
		for (int i = 0; i < N; i++) {
        int s1 = 0;
		for (int j = 0; j <= i; j++) {
			s1+=W[j];
		}
        int s2 = sum - s1;
        int sa = Math.abs(s1-s2);
        if(first || min > sa){
          min = sa;
        }
        if(first){
          first = false;
        }
		}
		System.out.println(min);
	}		
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int N = sc.nextInt();
		int[] W = new int[N];
        int sum = 0;
		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
            sum+=W[i];
		}
        int ans = 0;
        int min = 0;
        boolean first = true;
		for (int i = 0; i < N; i++) {
        int s1 = 0;
		for (int j = 0; j <= i; j++) {
			s1+=W[j];
		}
        int s2 = sum - s1;
        int sa = Math.abs(s1-s2);
        if(first || min > sa){
          min = sa;
        }
        if(first){
          first = false;
        }
		}
		System.out.println(min);
	}		
} Main
import 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];
        int sum = 0;
		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
            sum+=W[i];
		}
        int ans = 0;
        int min = 0;
        boolean first = true;
		for (int i = 0; i < N; i++) {
        int s1 = 0;
		for (int j = 0; j <= i; j++) {
			s1+=W[j];
		}
        int s2 = sum - s1;
        int sa = Math.abs(s1-s2);
        if(first || min > sa){
          min = sa;
        }
        if(first){
          first = false;
        }
		}
		System.out.println(min);
	}		
}
