import java.util.*;

class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	List<Integer> hoge = new ArrayList<>();
      	for(int i = 0; i < n; i++) {
      		hoge.add(sc.nextInt());
      	}
      	
      	int s1 = 0, s2 = 0, min = 1000;
      	for(int j = 1; j <= n; j++) {
      		int q = 0;
      		for(Integer p:hoge) {
      			if(q <= j) s1+=p;
      			else s2+=p;
      			q++;
      		}
      		if(min > Math.abs(s1 - s2)) min = Math.abs(s1 - s2);
      		s1 = 0;
      		s2 = 0;
      	}
      	System.out.println(min);
    }
} import java.util.*; util.* java class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	List<Integer> hoge = new ArrayList<>();
      	for(int i = 0; i < n; i++) {
      		hoge.add(sc.nextInt());
      	}
      	
      	int s1 = 0, s2 = 0, min = 1000;
      	for(int j = 1; j <= n; j++) {
      		int q = 0;
      		for(Integer p:hoge) {
      			if(q <= j) s1+=p;
      			else s2+=p;
      			q++;
      		}
      		if(min > Math.abs(s1 - s2)) min = Math.abs(s1 - s2);
      		s1 = 0;
      		s2 = 0;
      	}
      	System.out.println(min);
    }
} Main public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	List<Integer> hoge = new ArrayList<>();
      	for(int i = 0; i < n; i++) {
      		hoge.add(sc.nextInt());
      	}
      	
      	int s1 = 0, s2 = 0, min = 1000;
      	for(int j = 1; j <= n; j++) {
      		int q = 0;
      		for(Integer p:hoge) {
      			if(q <= j) s1+=p;
      			else s2+=p;
      			q++;
      		}
      		if(min > Math.abs(s1 - s2)) min = Math.abs(s1 - s2);
      		s1 = 0;
      		s2 = 0;
      	}
      	System.out.println(min);
    } main {
    	Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	List<Integer> hoge = new ArrayList<>();
      	for(int i = 0; i < n; i++) {
      		hoge.add(sc.nextInt());
      	}
      	
      	int s1 = 0, s2 = 0, min = 1000;
      	for(int j = 1; j <= n; j++) {
      		int q = 0;
      		for(Integer p:hoge) {
      			if(q <= j) s1+=p;
      			else s2+=p;
      			q++;
      		}
      		if(min > Math.abs(s1 - s2)) min = Math.abs(s1 - s2);
      		s1 = 0;
      		s2 = 0;
      	}
      	System.out.println(min);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc List<Integer> hoge = new ArrayList<>(); hoge new ArrayList<>() for(int i = 0; i < n; i++) {
      		hoge.add(sc.nextInt());
      	} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      		hoge.add(sc.nextInt());
      	} {
      		hoge.add(sc.nextInt());
      	} hoge.add(sc.nextInt()) hoge.add hoge sc.nextInt() sc.nextInt sc int s1 = 0 s1 0 s2 = 0 s2 0 min = 1000; min 1000 for(int j = 1; j <= n; j++) {
      		int q = 0;
      		for(Integer p:hoge) {
      			if(q <= j) s1+=p;
      			else s2+=p;
      			q++;
      		}
      		if(min > Math.abs(s1 - s2)) min = Math.abs(s1 - s2);
      		s1 = 0;
      		s2 = 0;
      	} int j = 1; int j = 1; j 1 j <= n j n j++ j++ j {
      		int q = 0;
      		for(Integer p:hoge) {
      			if(q <= j) s1+=p;
      			else s2+=p;
      			q++;
      		}
      		if(min > Math.abs(s1 - s2)) min = Math.abs(s1 - s2);
      		s1 = 0;
      		s2 = 0;
      	} {
      		int q = 0;
      		for(Integer p:hoge) {
      			if(q <= j) s1+=p;
      			else s2+=p;
      			q++;
      		}
      		if(min > Math.abs(s1 - s2)) min = Math.abs(s1 - s2);
      		s1 = 0;
      		s2 = 0;
      	} int q = 0; q 0 for(Integer p:hoge) {
      			if(q <= j) s1+=p;
      			else s2+=p;
      			q++;
      		} Integer p hoge {
      			if(q <= j) s1+=p;
      			else s2+=p;
      			q++;
      		} {
      			if(q <= j) s1+=p;
      			else s2+=p;
      			q++;
      		} if(q <= j) s1+=p;
      			else s2+=p; q <= j q j s1+=p s1 p s2+=p s2 p q++ q if(min > Math.abs(s1 - s2)) min = Math.abs(s1 - s2); min > Math.abs(s1 - s2) min Math.abs(s1 - s2) Math.abs Math s1 - s2 s1 s2 min = Math.abs(s1 - s2) min Math.abs(s1 - s2) Math.abs Math s1 - s2 s1 s2 s1 = 0 s1 0 s2 = 0 s2 0 System.out.println(min) System.out.println System.out System System.out min String[] args args
import java.util.*;

class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	List<Integer> hoge = new ArrayList<>();
      	for(int i = 0; i < n; i++) {
      		hoge.add(sc.nextInt());
      	}
      	
      	int s1 = 0, s2 = 0, min = 1000;
      	for(int j = 1; j <= n; j++) {
      		int q = 0;
      		for(Integer p:hoge) {
      			if(q <= j) s1+=p;
      			else s2+=p;
      			q++;
      		}
      		if(min > Math.abs(s1 - s2)) min = Math.abs(s1 - s2);
      		s1 = 0;
      		s2 = 0;
      	}
      	System.out.println(min);
    }
}