import java.util.Scanner;                                                                                            
                                                                                                                     
public class Main {                                                                                                  
	public static void main(String[] args) {                                                                         
		Scanner sc = new Scanner(System.in);                                                                         
                                                                                                                     
		int num = sc.nextInt();                                                                                      
                                                                                                                     
		int[] input = new int[num];                                                                                  
		for (int i = 0; i < num; i++) {                                                                              
			input[i] = sc.nextInt();                                                                                 
		}                                                                                                            
                                                                                                                     
		sc.close();                                                                                                  
                                                                                                                     
		int[] re = new int[num - 1];                                                                                 
		for (int i = 0; i < num - 1; i++) {                                                                          
			int a = 0;                                                                                               
			int b = 0;                                                                                               
			for (int j = 0; j < i + 1; j++) {                                                                        
				a += input[j];                                                                                       
			}                                                                                                        
			for (int k = i + 1; k < num; k++) {                                                                      
				b += input[k];                                                                                       
			}                                                                                                        
			if (a > b) {                                                                                             
				re[i] = a - b;                                                                                       
			} else {                                                                                                 
				re[i] = b - a;                                                                                       
			}                                                                                                        
		}                                                                                                            
                                                                                                                     
		int min = 1000;                                                                                              
		for (int i : re) {                                                                                           
			min = Math.min(min, i);                                                                                  
		}                                                                                                            
		System.out.println(min);                                                                                     
                                                                                                                     
	}                                                                                                                
                                                                                                                     
}                                                                                                                    
                                                                                                                      import java.util.Scanner; Scanner java.util public class Main {                                                                                                  
	public static void main(String[] args) {                                                                         
		Scanner sc = new Scanner(System.in);                                                                         
                                                                                                                     
		int num = sc.nextInt();                                                                                      
                                                                                                                     
		int[] input = new int[num];                                                                                  
		for (int i = 0; i < num; i++) {                                                                              
			input[i] = sc.nextInt();                                                                                 
		}                                                                                                            
                                                                                                                     
		sc.close();                                                                                                  
                                                                                                                     
		int[] re = new int[num - 1];                                                                                 
		for (int i = 0; i < num - 1; i++) {                                                                          
			int a = 0;                                                                                               
			int b = 0;                                                                                               
			for (int j = 0; j < i + 1; j++) {                                                                        
				a += input[j];                                                                                       
			}                                                                                                        
			for (int k = i + 1; k < num; k++) {                                                                      
				b += input[k];                                                                                       
			}                                                                                                        
			if (a > b) {                                                                                             
				re[i] = a - b;                                                                                       
			} else {                                                                                                 
				re[i] = b - a;                                                                                       
			}                                                                                                        
		}                                                                                                            
                                                                                                                     
		int min = 1000;                                                                                              
		for (int i : re) {                                                                                           
			min = Math.min(min, i);                                                                                  
		}                                                                                                            
		System.out.println(min);                                                                                     
                                                                                                                     
	}                                                                                                                
                                                                                                                     
} Main public static void main(String[] args) {                                                                         
		Scanner sc = new Scanner(System.in);                                                                         
                                                                                                                     
		int num = sc.nextInt();                                                                                      
                                                                                                                     
		int[] input = new int[num];                                                                                  
		for (int i = 0; i < num; i++) {                                                                              
			input[i] = sc.nextInt();                                                                                 
		}                                                                                                            
                                                                                                                     
		sc.close();                                                                                                  
                                                                                                                     
		int[] re = new int[num - 1];                                                                                 
		for (int i = 0; i < num - 1; i++) {                                                                          
			int a = 0;                                                                                               
			int b = 0;                                                                                               
			for (int j = 0; j < i + 1; j++) {                                                                        
				a += input[j];                                                                                       
			}                                                                                                        
			for (int k = i + 1; k < num; k++) {                                                                      
				b += input[k];                                                                                       
			}                                                                                                        
			if (a > b) {                                                                                             
				re[i] = a - b;                                                                                       
			} else {                                                                                                 
				re[i] = b - a;                                                                                       
			}                                                                                                        
		}                                                                                                            
                                                                                                                     
		int min = 1000;                                                                                              
		for (int i : re) {                                                                                           
			min = Math.min(min, i);                                                                                  
		}                                                                                                            
		System.out.println(min);                                                                                     
                                                                                                                     
	} main {                                                                         
		Scanner sc = new Scanner(System.in);                                                                         
                                                                                                                     
		int num = sc.nextInt();                                                                                      
                                                                                                                     
		int[] input = new int[num];                                                                                  
		for (int i = 0; i < num; i++) {                                                                              
			input[i] = sc.nextInt();                                                                                 
		}                                                                                                            
                                                                                                                     
		sc.close();                                                                                                  
                                                                                                                     
		int[] re = new int[num - 1];                                                                                 
		for (int i = 0; i < num - 1; i++) {                                                                          
			int a = 0;                                                                                               
			int b = 0;                                                                                               
			for (int j = 0; j < i + 1; j++) {                                                                        
				a += input[j];                                                                                       
			}                                                                                                        
			for (int k = i + 1; k < num; k++) {                                                                      
				b += input[k];                                                                                       
			}                                                                                                        
			if (a > b) {                                                                                             
				re[i] = a - b;                                                                                       
			} else {                                                                                                 
				re[i] = b - a;                                                                                       
			}                                                                                                        
		}                                                                                                            
                                                                                                                     
		int min = 1000;                                                                                              
		for (int i : re) {                                                                                           
			min = Math.min(min, i);                                                                                  
		}                                                                                                            
		System.out.println(min);                                                                                     
                                                                                                                     
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int num = sc.nextInt(); num sc.nextInt() sc.nextInt sc int[] input = new int[num]; input new int[num] num for (int i = 0; i < num; i++) {                                                                              
			input[i] = sc.nextInt();                                                                                 
		} int i = 0; int i = 0; i 0 i < num i num i++ i++ i {                                                                              
			input[i] = sc.nextInt();                                                                                 
		} {                                                                              
			input[i] = sc.nextInt();                                                                                 
		} input[i] = sc.nextInt() input[i] input i sc.nextInt() sc.nextInt sc sc.close() sc.close sc int[] re = new int[num - 1]; re new int[num - 1] num - 1 num 1 for (int i = 0; i < num - 1; i++) {                                                                          
			int a = 0;                                                                                               
			int b = 0;                                                                                               
			for (int j = 0; j < i + 1; j++) {                                                                        
				a += input[j];                                                                                       
			}                                                                                                        
			for (int k = i + 1; k < num; k++) {                                                                      
				b += input[k];                                                                                       
			}                                                                                                        
			if (a > b) {                                                                                             
				re[i] = a - b;                                                                                       
			} else {                                                                                                 
				re[i] = b - a;                                                                                       
			}                                                                                                        
		} int i = 0; int i = 0; i 0 i < num - 1 i num - 1 num 1 i++ i++ i {                                                                          
			int a = 0;                                                                                               
			int b = 0;                                                                                               
			for (int j = 0; j < i + 1; j++) {                                                                        
				a += input[j];                                                                                       
			}                                                                                                        
			for (int k = i + 1; k < num; k++) {                                                                      
				b += input[k];                                                                                       
			}                                                                                                        
			if (a > b) {                                                                                             
				re[i] = a - b;                                                                                       
			} else {                                                                                                 
				re[i] = b - a;                                                                                       
			}                                                                                                        
		} {                                                                          
			int a = 0;                                                                                               
			int b = 0;                                                                                               
			for (int j = 0; j < i + 1; j++) {                                                                        
				a += input[j];                                                                                       
			}                                                                                                        
			for (int k = i + 1; k < num; k++) {                                                                      
				b += input[k];                                                                                       
			}                                                                                                        
			if (a > b) {                                                                                             
				re[i] = a - b;                                                                                       
			} else {                                                                                                 
				re[i] = b - a;                                                                                       
			}                                                                                                        
		} int a = 0; a 0 int b = 0; b 0 for (int j = 0; j < i + 1; j++) {                                                                        
				a += input[j];                                                                                       
			} int j = 0; int j = 0; j 0 j < i + 1 j i + 1 i 1 j++ j++ j {                                                                        
				a += input[j];                                                                                       
			} {                                                                        
				a += input[j];                                                                                       
			} a += input[j] a input[j] input j for (int k = i + 1; k < num; k++) {                                                                      
				b += input[k];                                                                                       
			} int k = i + 1; int k = i + 1; k i + 1 i 1 k < num k num k++ k++ k {                                                                      
				b += input[k];                                                                                       
			} {                                                                      
				b += input[k];                                                                                       
			} b += input[k] b input[k] input k if (a > b) {                                                                                             
				re[i] = a - b;                                                                                       
			} else {                                                                                                 
				re[i] = b - a;                                                                                       
			} a > b a b {                                                                                             
				re[i] = a - b;                                                                                       
			} re[i] = a - b re[i] re i a - b a b {                                                                                                 
				re[i] = b - a;                                                                                       
			} re[i] = b - a re[i] re i b - a b a int min = 1000; min 1000 for (int i : re) {                                                                                           
			min = Math.min(min, i);                                                                                  
		} int i re {                                                                                           
			min = Math.min(min, i);                                                                                  
		} {                                                                                           
			min = Math.min(min, i);                                                                                  
		} min = Math.min(min, i) min Math.min(min, i) Math.min Math min i 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 num = sc.nextInt();                                                                                      
                                                                                                                     
		int[] input = new int[num];                                                                                  
		for (int i = 0; i < num; i++) {                                                                              
			input[i] = sc.nextInt();                                                                                 
		}                                                                                                            
                                                                                                                     
		sc.close();                                                                                                  
                                                                                                                     
		int[] re = new int[num - 1];                                                                                 
		for (int i = 0; i < num - 1; i++) {                                                                          
			int a = 0;                                                                                               
			int b = 0;                                                                                               
			for (int j = 0; j < i + 1; j++) {                                                                        
				a += input[j];                                                                                       
			}                                                                                                        
			for (int k = i + 1; k < num; k++) {                                                                      
				b += input[k];                                                                                       
			}                                                                                                        
			if (a > b) {                                                                                             
				re[i] = a - b;                                                                                       
			} else {                                                                                                 
				re[i] = b - a;                                                                                       
			}                                                                                                        
		}                                                                                                            
                                                                                                                     
		int min = 1000;                                                                                              
		for (int i : re) {                                                                                           
			min = Math.min(min, i);                                                                                  
		}                                                                                                            
		System.out.println(min);                                                                                     
                                                                                                                     
	}                                                                                                                
                                                                                                                     
} public class Main {                                                                                                  
	public static void main(String[] args) {                                                                         
		Scanner sc = new Scanner(System.in);                                                                         
                                                                                                                     
		int num = sc.nextInt();                                                                                      
                                                                                                                     
		int[] input = new int[num];                                                                                  
		for (int i = 0; i < num; i++) {                                                                              
			input[i] = sc.nextInt();                                                                                 
		}                                                                                                            
                                                                                                                     
		sc.close();                                                                                                  
                                                                                                                     
		int[] re = new int[num - 1];                                                                                 
		for (int i = 0; i < num - 1; i++) {                                                                          
			int a = 0;                                                                                               
			int b = 0;                                                                                               
			for (int j = 0; j < i + 1; j++) {                                                                        
				a += input[j];                                                                                       
			}                                                                                                        
			for (int k = i + 1; k < num; k++) {                                                                      
				b += input[k];                                                                                       
			}                                                                                                        
			if (a > b) {                                                                                             
				re[i] = a - b;                                                                                       
			} else {                                                                                                 
				re[i] = b - a;                                                                                       
			}                                                                                                        
		}                                                                                                            
                                                                                                                     
		int min = 1000;                                                                                              
		for (int i : re) {                                                                                           
			min = Math.min(min, i);                                                                                  
		}                                                                                                            
		System.out.println(min);                                                                                     
                                                                                                                     
	}                                                                                                                
                                                                                                                     
} Main
import java.util.Scanner;                                                                                            
                                                                                                                     
public class Main {                                                                                                  
	public static void main(String[] args) {                                                                         
		Scanner sc = new Scanner(System.in);                                                                         
                                                                                                                     
		int num = sc.nextInt();                                                                                      
                                                                                                                     
		int[] input = new int[num];                                                                                  
		for (int i = 0; i < num; i++) {                                                                              
			input[i] = sc.nextInt();                                                                                 
		}                                                                                                            
                                                                                                                     
		sc.close();                                                                                                  
                                                                                                                     
		int[] re = new int[num - 1];                                                                                 
		for (int i = 0; i < num - 1; i++) {                                                                          
			int a = 0;                                                                                               
			int b = 0;                                                                                               
			for (int j = 0; j < i + 1; j++) {                                                                        
				a += input[j];                                                                                       
			}                                                                                                        
			for (int k = i + 1; k < num; k++) {                                                                      
				b += input[k];                                                                                       
			}                                                                                                        
			if (a > b) {                                                                                             
				re[i] = a - b;                                                                                       
			} else {                                                                                                 
				re[i] = b - a;                                                                                       
			}                                                                                                        
		}                                                                                                            
                                                                                                                     
		int min = 1000;                                                                                              
		for (int i : re) {                                                                                           
			min = Math.min(min, i);                                                                                  
		}                                                                                                            
		System.out.println(min);                                                                                     
                                                                                                                     
	}                                                                                                                
                                                                                                                     
}                                                                                                                    
                                                                                                                     