import java.util.*;
import java.lang.*;
import java.io.*;

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[] wdif = new int[n-1];
	int s1 = 0;
	int s2 = 0;
	for(int i = 0; i < w.length; i++){
		w[i] = sc.nextInt();	
	}
	for(int t = 0; t < wdif.length; t++){
		for(int i = 0; i < w.length; i++){
			if(i<=t){
				s1 += w[i];
			}else{
				s2 += w[i];
			}
		}
		wdif[t] = Math.abs(s1 - s2);
		s1 = 0;
		s2 = 0;
	}
	System.out.println(minAr(wdif));
}

static int minAr(int[] a){
	int min=0;
	for(int i = 0; i < a.length; i++){
		if(i==0){
			min = a[i];
		}else{
			min = Math.min(min,a[i]);
		}
	}
	return min;
}
} import java.util.*; util.* java import java.lang.*; lang.* java import java.io.*; io.* 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[] wdif = new int[n-1];
	int s1 = 0;
	int s2 = 0;
	for(int i = 0; i < w.length; i++){
		w[i] = sc.nextInt();	
	}
	for(int t = 0; t < wdif.length; t++){
		for(int i = 0; i < w.length; i++){
			if(i<=t){
				s1 += w[i];
			}else{
				s2 += w[i];
			}
		}
		wdif[t] = Math.abs(s1 - s2);
		s1 = 0;
		s2 = 0;
	}
	System.out.println(minAr(wdif));
}

static int minAr(int[] a){
	int min=0;
	for(int i = 0; i < a.length; i++){
		if(i==0){
			min = a[i];
		}else{
			min = Math.min(min,a[i]);
		}
	}
	return min;
}
} Main public static void main (String[] args){
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int[] w = new int[n];
	int[] wdif = new int[n-1];
	int s1 = 0;
	int s2 = 0;
	for(int i = 0; i < w.length; i++){
		w[i] = sc.nextInt();	
	}
	for(int t = 0; t < wdif.length; t++){
		for(int i = 0; i < w.length; i++){
			if(i<=t){
				s1 += w[i];
			}else{
				s2 += w[i];
			}
		}
		wdif[t] = Math.abs(s1 - s2);
		s1 = 0;
		s2 = 0;
	}
	System.out.println(minAr(wdif));
} main {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int[] w = new int[n];
	int[] wdif = new int[n-1];
	int s1 = 0;
	int s2 = 0;
	for(int i = 0; i < w.length; i++){
		w[i] = sc.nextInt();	
	}
	for(int t = 0; t < wdif.length; t++){
		for(int i = 0; i < w.length; i++){
			if(i<=t){
				s1 += w[i];
			}else{
				s2 += w[i];
			}
		}
		wdif[t] = Math.abs(s1 - s2);
		s1 = 0;
		s2 = 0;
	}
	System.out.println(minAr(wdif));
} 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[] wdif = new int[n-1]; wdif new int[n-1] n-1 n 1 int s1 = 0; s1 0 int s2 = 0; s2 0 for(int i = 0; i < w.length; i++){
		w[i] = sc.nextInt();	
	} int i = 0; int i = 0; i 0 i < w.length i w.length w w.length i++ i++ i {
		w[i] = sc.nextInt();	
	} {
		w[i] = sc.nextInt();	
	} w[i] = sc.nextInt() w[i] w i sc.nextInt() sc.nextInt sc for(int t = 0; t < wdif.length; t++){
		for(int i = 0; i < w.length; i++){
			if(i<=t){
				s1 += w[i];
			}else{
				s2 += w[i];
			}
		}
		wdif[t] = Math.abs(s1 - s2);
		s1 = 0;
		s2 = 0;
	} int t = 0; int t = 0; t 0 t < wdif.length t wdif.length wdif wdif.length t++ t++ t {
		for(int i = 0; i < w.length; i++){
			if(i<=t){
				s1 += w[i];
			}else{
				s2 += w[i];
			}
		}
		wdif[t] = Math.abs(s1 - s2);
		s1 = 0;
		s2 = 0;
	} {
		for(int i = 0; i < w.length; i++){
			if(i<=t){
				s1 += w[i];
			}else{
				s2 += w[i];
			}
		}
		wdif[t] = Math.abs(s1 - s2);
		s1 = 0;
		s2 = 0;
	} for(int i = 0; i < w.length; i++){
			if(i<=t){
				s1 += w[i];
			}else{
				s2 += w[i];
			}
		} int i = 0; int i = 0; i 0 i < w.length i w.length w w.length i++ i++ i {
			if(i<=t){
				s1 += w[i];
			}else{
				s2 += w[i];
			}
		} {
			if(i<=t){
				s1 += w[i];
			}else{
				s2 += w[i];
			}
		} if(i<=t){
				s1 += w[i];
			}else{
				s2 += w[i];
			} i<=t i t {
				s1 += w[i];
			} s1 += w[i] s1 w[i] w i {
				s2 += w[i];
			} s2 += w[i] s2 w[i] w i wdif[t] = Math.abs(s1 - s2) wdif[t] wdif t Math.abs(s1 - s2) Math.abs Math s1 - s2 s1 s2 s1 = 0 s1 0 s2 = 0 s2 0 System.out.println(minAr(wdif)) System.out.println System.out System System.out minAr(wdif) minAr wdif String[] args args static int minAr(int[] a){
	int min=0;
	for(int i = 0; i < a.length; i++){
		if(i==0){
			min = a[i];
		}else{
			min = Math.min(min,a[i]);
		}
	}
	return min;
} minAr {
	int min=0;
	for(int i = 0; i < a.length; i++){
		if(i==0){
			min = a[i];
		}else{
			min = Math.min(min,a[i]);
		}
	}
	return min;
} int min=0; min 0 for(int i = 0; i < a.length; i++){
		if(i==0){
			min = a[i];
		}else{
			min = Math.min(min,a[i]);
		}
	} int i = 0; int i = 0; i 0 i < a.length i a.length a a.length i++ i++ i {
		if(i==0){
			min = a[i];
		}else{
			min = Math.min(min,a[i]);
		}
	} {
		if(i==0){
			min = a[i];
		}else{
			min = Math.min(min,a[i]);
		}
	} if(i==0){
			min = a[i];
		}else{
			min = Math.min(min,a[i]);
		} i==0 i 0 {
			min = a[i];
		} min = a[i] min a[i] a i {
			min = Math.min(min,a[i]);
		} min = Math.min(min,a[i]) min Math.min(min,a[i]) Math.min Math min a[i] a i return min; min int[] a a 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[] wdif = new int[n-1];
	int s1 = 0;
	int s2 = 0;
	for(int i = 0; i < w.length; i++){
		w[i] = sc.nextInt();	
	}
	for(int t = 0; t < wdif.length; t++){
		for(int i = 0; i < w.length; i++){
			if(i<=t){
				s1 += w[i];
			}else{
				s2 += w[i];
			}
		}
		wdif[t] = Math.abs(s1 - s2);
		s1 = 0;
		s2 = 0;
	}
	System.out.println(minAr(wdif));
}

static int minAr(int[] a){
	int min=0;
	for(int i = 0; i < a.length; i++){
		if(i==0){
			min = a[i];
		}else{
			min = Math.min(min,a[i]);
		}
	}
	return 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[] wdif = new int[n-1];
	int s1 = 0;
	int s2 = 0;
	for(int i = 0; i < w.length; i++){
		w[i] = sc.nextInt();	
	}
	for(int t = 0; t < wdif.length; t++){
		for(int i = 0; i < w.length; i++){
			if(i<=t){
				s1 += w[i];
			}else{
				s2 += w[i];
			}
		}
		wdif[t] = Math.abs(s1 - s2);
		s1 = 0;
		s2 = 0;
	}
	System.out.println(minAr(wdif));
}

static int minAr(int[] a){
	int min=0;
	for(int i = 0; i < a.length; i++){
		if(i==0){
			min = a[i];
		}else{
			min = Math.min(min,a[i]);
		}
	}
	return min;
}
} Main
import java.util.*;
import java.lang.*;
import java.io.*;

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[] wdif = new int[n-1];
	int s1 = 0;
	int s2 = 0;
	for(int i = 0; i < w.length; i++){
		w[i] = sc.nextInt();	
	}
	for(int t = 0; t < wdif.length; t++){
		for(int i = 0; i < w.length; i++){
			if(i<=t){
				s1 += w[i];
			}else{
				s2 += w[i];
			}
		}
		wdif[t] = Math.abs(s1 - s2);
		s1 = 0;
		s2 = 0;
	}
	System.out.println(minAr(wdif));
}

static int minAr(int[] a){
	int min=0;
	for(int i = 0; i < a.length; i++){
		if(i==0){
			min = a[i];
		}else{
			min = Math.min(min,a[i]);
		}
	}
	return min;
}
}
