import java.util.*;

public class Main {
	
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
	
		
		int n=sc.nextInt();
		int sum=0;
		int[] w=new int[n];		
		for(int i=0;i<n;i++){
			w[i]=sc.nextInt();
			sum=sum+w[i];
		}
		 int l=sum;
		 int f =0;
		 int dif=sum;
		 
		for(int i=0;i<n;i++){
			l=l-w[i];
			f=f+w[i];
			if(Math.abs(l-f)>dif)break;
			dif=Math.abs(l-f);
		}
		
		
		System.out.println(dif);
	}

} 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 sum=0;
		int[] w=new int[n];		
		for(int i=0;i<n;i++){
			w[i]=sc.nextInt();
			sum=sum+w[i];
		}
		 int l=sum;
		 int f =0;
		 int dif=sum;
		 
		for(int i=0;i<n;i++){
			l=l-w[i];
			f=f+w[i];
			if(Math.abs(l-f)>dif)break;
			dif=Math.abs(l-f);
		}
		
		
		System.out.println(dif);
	}

} Main public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
	
		
		int n=sc.nextInt();
		int sum=0;
		int[] w=new int[n];		
		for(int i=0;i<n;i++){
			w[i]=sc.nextInt();
			sum=sum+w[i];
		}
		 int l=sum;
		 int f =0;
		 int dif=sum;
		 
		for(int i=0;i<n;i++){
			l=l-w[i];
			f=f+w[i];
			if(Math.abs(l-f)>dif)break;
			dif=Math.abs(l-f);
		}
		
		
		System.out.println(dif);
	} main {
		Scanner sc=new Scanner(System.in);
	
		
		int n=sc.nextInt();
		int sum=0;
		int[] w=new int[n];		
		for(int i=0;i<n;i++){
			w[i]=sc.nextInt();
			sum=sum+w[i];
		}
		 int l=sum;
		 int f =0;
		 int dif=sum;
		 
		for(int i=0;i<n;i++){
			l=l-w[i];
			f=f+w[i];
			if(Math.abs(l-f)>dif)break;
			dif=Math.abs(l-f);
		}
		
		
		System.out.println(dif);
	} Scanner sc=new Scanner(System.in); sc new Scanner(System.in) int n=sc.nextInt(); n sc.nextInt() sc.nextInt sc int sum=0; sum 0 int[] w=new int[n]; w new int[n] n for(int i=0;i<n;i++){
			w[i]=sc.nextInt();
			sum=sum+w[i];
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			w[i]=sc.nextInt();
			sum=sum+w[i];
		} {
			w[i]=sc.nextInt();
			sum=sum+w[i];
		} w[i]=sc.nextInt() w[i] w i sc.nextInt() sc.nextInt sc sum=sum+w[i] sum sum+w[i] sum w[i] w i int l=sum; l sum int f =0; f 0 int dif=sum; dif sum for(int i=0;i<n;i++){
			l=l-w[i];
			f=f+w[i];
			if(Math.abs(l-f)>dif)break;
			dif=Math.abs(l-f);
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			l=l-w[i];
			f=f+w[i];
			if(Math.abs(l-f)>dif)break;
			dif=Math.abs(l-f);
		} {
			l=l-w[i];
			f=f+w[i];
			if(Math.abs(l-f)>dif)break;
			dif=Math.abs(l-f);
		} l=l-w[i] l l-w[i] l w[i] w i f=f+w[i] f f+w[i] f w[i] w i if(Math.abs(l-f)>dif)break; Math.abs(l-f)>dif Math.abs(l-f) Math.abs Math l-f l f dif break; dif=Math.abs(l-f) dif Math.abs(l-f) Math.abs Math l-f l f System.out.println(dif) System.out.println System.out System System.out dif String[] args args public class Main {
	
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
	
		
		int n=sc.nextInt();
		int sum=0;
		int[] w=new int[n];		
		for(int i=0;i<n;i++){
			w[i]=sc.nextInt();
			sum=sum+w[i];
		}
		 int l=sum;
		 int f =0;
		 int dif=sum;
		 
		for(int i=0;i<n;i++){
			l=l-w[i];
			f=f+w[i];
			if(Math.abs(l-f)>dif)break;
			dif=Math.abs(l-f);
		}
		
		
		System.out.println(dif);
	}

} public class Main {
	
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
	
		
		int n=sc.nextInt();
		int sum=0;
		int[] w=new int[n];		
		for(int i=0;i<n;i++){
			w[i]=sc.nextInt();
			sum=sum+w[i];
		}
		 int l=sum;
		 int f =0;
		 int dif=sum;
		 
		for(int i=0;i<n;i++){
			l=l-w[i];
			f=f+w[i];
			if(Math.abs(l-f)>dif)break;
			dif=Math.abs(l-f);
		}
		
		
		System.out.println(dif);
	}

} Main
import java.util.*;

public class Main {
	
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
	
		
		int n=sc.nextInt();
		int sum=0;
		int[] w=new int[n];		
		for(int i=0;i<n;i++){
			w[i]=sc.nextInt();
			sum=sum+w[i];
		}
		 int l=sum;
		 int f =0;
		 int dif=sum;
		 
		for(int i=0;i<n;i++){
			l=l-w[i];
			f=f+w[i];
			if(Math.abs(l-f)>dif)break;
			dif=Math.abs(l-f);
		}
		
		
		System.out.println(dif);
	}

}