import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
//		int m = scan.nextInt();
//		int a = scan.nextInt();
		
		int[] ww = new int[n];
		int s1 = 0;
		int s2 = 0;
		int ss = 0;
		for(int i=0;i<n;i++) {
			int w = scan.nextInt();
			ww[i] = w;
		}
		for(int i=1; i<n; i++) {
			for(int j=0;j<n;j++) {
				if(j<=i) {
					s1+=ww[j];
				}else {
					s2+=ww[j];
				}
			}
  
			if(i==1) {
			ss = Math.abs(s2-s1);
			}if(ss>Math.abs(s2-s1)) {
				ss = Math.abs(s2-s1);
			}
			s1=0;
			s2=0;
			
		}
		System.out.println(ss);
		
	}

} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
//		int m = scan.nextInt();
//		int a = scan.nextInt();
		
		int[] ww = new int[n];
		int s1 = 0;
		int s2 = 0;
		int ss = 0;
		for(int i=0;i<n;i++) {
			int w = scan.nextInt();
			ww[i] = w;
		}
		for(int i=1; i<n; i++) {
			for(int j=0;j<n;j++) {
				if(j<=i) {
					s1+=ww[j];
				}else {
					s2+=ww[j];
				}
			}
  
			if(i==1) {
			ss = Math.abs(s2-s1);
			}if(ss>Math.abs(s2-s1)) {
				ss = Math.abs(s2-s1);
			}
			s1=0;
			s2=0;
			
		}
		System.out.println(ss);
		
	}

} Main public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
//		int m = scan.nextInt();
//		int a = scan.nextInt();
		
		int[] ww = new int[n];
		int s1 = 0;
		int s2 = 0;
		int ss = 0;
		for(int i=0;i<n;i++) {
			int w = scan.nextInt();
			ww[i] = w;
		}
		for(int i=1; i<n; i++) {
			for(int j=0;j<n;j++) {
				if(j<=i) {
					s1+=ww[j];
				}else {
					s2+=ww[j];
				}
			}
  
			if(i==1) {
			ss = Math.abs(s2-s1);
			}if(ss>Math.abs(s2-s1)) {
				ss = Math.abs(s2-s1);
			}
			s1=0;
			s2=0;
			
		}
		System.out.println(ss);
		
	} main {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
//		int m = scan.nextInt();
//		int a = scan.nextInt();
		
		int[] ww = new int[n];
		int s1 = 0;
		int s2 = 0;
		int ss = 0;
		for(int i=0;i<n;i++) {
			int w = scan.nextInt();
			ww[i] = w;
		}
		for(int i=1; i<n; i++) {
			for(int j=0;j<n;j++) {
				if(j<=i) {
					s1+=ww[j];
				}else {
					s2+=ww[j];
				}
			}
  
			if(i==1) {
			ss = Math.abs(s2-s1);
			}if(ss>Math.abs(s2-s1)) {
				ss = Math.abs(s2-s1);
			}
			s1=0;
			s2=0;
			
		}
		System.out.println(ss);
		
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int[] ww = new int[n]; ww new int[n] n int s1 = 0; s1 0 int s2 = 0; s2 0 int ss = 0; ss 0 for(int i=0;i<n;i++) {
			int w = scan.nextInt();
			ww[i] = w;
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			int w = scan.nextInt();
			ww[i] = w;
		} {
			int w = scan.nextInt();
			ww[i] = w;
		} int w = scan.nextInt(); w scan.nextInt() scan.nextInt scan ww[i] = w ww[i] ww i w for(int i=1; i<n; i++) {
			for(int j=0;j<n;j++) {
				if(j<=i) {
					s1+=ww[j];
				}else {
					s2+=ww[j];
				}
			}
  
			if(i==1) {
			ss = Math.abs(s2-s1);
			}if(ss>Math.abs(s2-s1)) {
				ss = Math.abs(s2-s1);
			}
			s1=0;
			s2=0;
			
		} int i=1; int i=1; i 1 i<n i n i++ i++ i {
			for(int j=0;j<n;j++) {
				if(j<=i) {
					s1+=ww[j];
				}else {
					s2+=ww[j];
				}
			}
  
			if(i==1) {
			ss = Math.abs(s2-s1);
			}if(ss>Math.abs(s2-s1)) {
				ss = Math.abs(s2-s1);
			}
			s1=0;
			s2=0;
			
		} {
			for(int j=0;j<n;j++) {
				if(j<=i) {
					s1+=ww[j];
				}else {
					s2+=ww[j];
				}
			}
  
			if(i==1) {
			ss = Math.abs(s2-s1);
			}if(ss>Math.abs(s2-s1)) {
				ss = Math.abs(s2-s1);
			}
			s1=0;
			s2=0;
			
		} for(int j=0;j<n;j++) {
				if(j<=i) {
					s1+=ww[j];
				}else {
					s2+=ww[j];
				}
			} int j=0; int j=0; j 0 j<n j n j++ j++ j {
				if(j<=i) {
					s1+=ww[j];
				}else {
					s2+=ww[j];
				}
			} {
				if(j<=i) {
					s1+=ww[j];
				}else {
					s2+=ww[j];
				}
			} if(j<=i) {
					s1+=ww[j];
				}else {
					s2+=ww[j];
				} j<=i j i {
					s1+=ww[j];
				} s1+=ww[j] s1 ww[j] ww j {
					s2+=ww[j];
				} s2+=ww[j] s2 ww[j] ww j if(i==1) {
			ss = Math.abs(s2-s1);
			} i==1 i 1 {
			ss = Math.abs(s2-s1);
			} ss = Math.abs(s2-s1) ss Math.abs(s2-s1) Math.abs Math s2-s1 s2 s1 if(ss>Math.abs(s2-s1)) {
				ss = Math.abs(s2-s1);
			} ss>Math.abs(s2-s1) ss Math.abs(s2-s1) Math.abs Math s2-s1 s2 s1 {
				ss = Math.abs(s2-s1);
			} ss = Math.abs(s2-s1) ss Math.abs(s2-s1) Math.abs Math s2-s1 s2 s1 s1=0 s1 0 s2=0 s2 0 System.out.println(ss) System.out.println System.out System System.out ss String[] args args public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
//		int m = scan.nextInt();
//		int a = scan.nextInt();
		
		int[] ww = new int[n];
		int s1 = 0;
		int s2 = 0;
		int ss = 0;
		for(int i=0;i<n;i++) {
			int w = scan.nextInt();
			ww[i] = w;
		}
		for(int i=1; i<n; i++) {
			for(int j=0;j<n;j++) {
				if(j<=i) {
					s1+=ww[j];
				}else {
					s2+=ww[j];
				}
			}
  
			if(i==1) {
			ss = Math.abs(s2-s1);
			}if(ss>Math.abs(s2-s1)) {
				ss = Math.abs(s2-s1);
			}
			s1=0;
			s2=0;
			
		}
		System.out.println(ss);
		
	}

} public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
//		int m = scan.nextInt();
//		int a = scan.nextInt();
		
		int[] ww = new int[n];
		int s1 = 0;
		int s2 = 0;
		int ss = 0;
		for(int i=0;i<n;i++) {
			int w = scan.nextInt();
			ww[i] = w;
		}
		for(int i=1; i<n; i++) {
			for(int j=0;j<n;j++) {
				if(j<=i) {
					s1+=ww[j];
				}else {
					s2+=ww[j];
				}
			}
  
			if(i==1) {
			ss = Math.abs(s2-s1);
			}if(ss>Math.abs(s2-s1)) {
				ss = Math.abs(s2-s1);
			}
			s1=0;
			s2=0;
			
		}
		System.out.println(ss);
		
	}

} Main
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
//		int m = scan.nextInt();
//		int a = scan.nextInt();
		
		int[] ww = new int[n];
		int s1 = 0;
		int s2 = 0;
		int ss = 0;
		for(int i=0;i<n;i++) {
			int w = scan.nextInt();
			ww[i] = w;
		}
		for(int i=1; i<n; i++) {
			for(int j=0;j<n;j++) {
				if(j<=i) {
					s1+=ww[j];
				}else {
					s2+=ww[j];
				}
			}
  
			if(i==1) {
			ss = Math.abs(s2-s1);
			}if(ss>Math.abs(s2-s1)) {
				ss = Math.abs(s2-s1);
			}
			s1=0;
			s2=0;
			
		}
		System.out.println(ss);
		
	}

}