import java.io.*;
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 = 100000000;
		for(int i=0;i<N;i++){
			int sum1 = 0;
			int sum2 = 0;
			for(int j=0;j<i;j++){
				sum1 += w[j];
			}
			for(int k=i;k<N;k++){
				sum2 += w[k];
			}
			ans = Math.min(ans, (int)Math.abs(sum1-sum2));
		}
		System.out.println(ans);
	}
} import java.io.*; io.* java 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 = 100000000;
		for(int i=0;i<N;i++){
			int sum1 = 0;
			int sum2 = 0;
			for(int j=0;j<i;j++){
				sum1 += w[j];
			}
			for(int k=i;k<N;k++){
				sum2 += w[k];
			}
			ans = Math.min(ans, (int)Math.abs(sum1-sum2));
		}
		System.out.println(ans);
	}
} 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 = 100000000;
		for(int i=0;i<N;i++){
			int sum1 = 0;
			int sum2 = 0;
			for(int j=0;j<i;j++){
				sum1 += w[j];
			}
			for(int k=i;k<N;k++){
				sum2 += w[k];
			}
			ans = Math.min(ans, (int)Math.abs(sum1-sum2));
		}
		System.out.println(ans);
	} 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 = 100000000;
		for(int i=0;i<N;i++){
			int sum1 = 0;
			int sum2 = 0;
			for(int j=0;j<i;j++){
				sum1 += w[j];
			}
			for(int k=i;k<N;k++){
				sum2 += w[k];
			}
			ans = Math.min(ans, (int)Math.abs(sum1-sum2));
		}
		System.out.println(ans);
	} 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 = 100000000; ans 100000000 for(int i=0;i<N;i++){
			int sum1 = 0;
			int sum2 = 0;
			for(int j=0;j<i;j++){
				sum1 += w[j];
			}
			for(int k=i;k<N;k++){
				sum2 += w[k];
			}
			ans = Math.min(ans, (int)Math.abs(sum1-sum2));
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			int sum1 = 0;
			int sum2 = 0;
			for(int j=0;j<i;j++){
				sum1 += w[j];
			}
			for(int k=i;k<N;k++){
				sum2 += w[k];
			}
			ans = Math.min(ans, (int)Math.abs(sum1-sum2));
		} {
			int sum1 = 0;
			int sum2 = 0;
			for(int j=0;j<i;j++){
				sum1 += w[j];
			}
			for(int k=i;k<N;k++){
				sum2 += w[k];
			}
			ans = Math.min(ans, (int)Math.abs(sum1-sum2));
		} int sum1 = 0; sum1 0 int sum2 = 0; sum2 0 for(int j=0;j<i;j++){
				sum1 += w[j];
			} int j=0; int j=0; j 0 j<i j i j++ j++ j {
				sum1 += w[j];
			} {
				sum1 += w[j];
			} sum1 += w[j] sum1 w[j] w j for(int k=i;k<N;k++){
				sum2 += w[k];
			} int k=i; int k=i; k i k<N k N k++ k++ k {
				sum2 += w[k];
			} {
				sum2 += w[k];
			} sum2 += w[k] sum2 w[k] w k ans = Math.min(ans, (int)Math.abs(sum1-sum2)) ans Math.min(ans, (int)Math.abs(sum1-sum2)) Math.min Math ans (int)Math.abs(sum1-sum2) Math.abs Math sum1-sum2 sum1 sum2 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){
		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 = 100000000;
		for(int i=0;i<N;i++){
			int sum1 = 0;
			int sum2 = 0;
			for(int j=0;j<i;j++){
				sum1 += w[j];
			}
			for(int k=i;k<N;k++){
				sum2 += w[k];
			}
			ans = Math.min(ans, (int)Math.abs(sum1-sum2));
		}
		System.out.println(ans);
	}
} 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 = 100000000;
		for(int i=0;i<N;i++){
			int sum1 = 0;
			int sum2 = 0;
			for(int j=0;j<i;j++){
				sum1 += w[j];
			}
			for(int k=i;k<N;k++){
				sum2 += w[k];
			}
			ans = Math.min(ans, (int)Math.abs(sum1-sum2));
		}
		System.out.println(ans);
	}
} Main
import java.io.*;
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 = 100000000;
		for(int i=0;i<N;i++){
			int sum1 = 0;
			int sum2 = 0;
			for(int j=0;j<i;j++){
				sum1 += w[j];
			}
			for(int k=i;k<N;k++){
				sum2 += w[k];
			}
			ans = Math.min(ans, (int)Math.abs(sum1-sum2));
		}
		System.out.println(ans);
	}
}