import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    	
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();

		ArrayList<Integer> ls4 = new ArrayList<Integer>();

		for (int i = 0; i < N;i ++ ){
			// 重りを入力
			ls4.add( sc.nextInt());
		}

		int ans_a = 0;
		int ans_b = 0;//合計
		int T = 0;
		int min = 999999999;
		int ans = 0;
		
		while (T < N) {
			for (int i = 0; i < N;i ++ ){
				if(i < T){
					ans_a = ans_a + ls4.get(i);
				}else{
					ans_b = ans_b + ls4.get(i);
				}
			}
			if(min > Math.abs(ans_a - ans_b)){
				min = Math.abs(ans_a - ans_b);
				ans = T;
			}
			T ++;
			ans_a = 0;
			ans_b = 0;
		}
	    
		System.out.println(min);

   		sc.close();
        return ;

    }
    
}
 import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.HashMap; HashMap java.util import java.util.Map; Map java.util import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
    	
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();

		ArrayList<Integer> ls4 = new ArrayList<Integer>();

		for (int i = 0; i < N;i ++ ){
			// 重りを入力
			ls4.add( sc.nextInt());
		}

		int ans_a = 0;
		int ans_b = 0;//合計
		int T = 0;
		int min = 999999999;
		int ans = 0;
		
		while (T < N) {
			for (int i = 0; i < N;i ++ ){
				if(i < T){
					ans_a = ans_a + ls4.get(i);
				}else{
					ans_b = ans_b + ls4.get(i);
				}
			}
			if(min > Math.abs(ans_a - ans_b)){
				min = Math.abs(ans_a - ans_b);
				ans = T;
			}
			T ++;
			ans_a = 0;
			ans_b = 0;
		}
	    
		System.out.println(min);

   		sc.close();
        return ;

    }
    
} Main public static void main(String[] args) {
    	
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();

		ArrayList<Integer> ls4 = new ArrayList<Integer>();

		for (int i = 0; i < N;i ++ ){
			// 重りを入力
			ls4.add( sc.nextInt());
		}

		int ans_a = 0;
		int ans_b = 0;//合計
		int T = 0;
		int min = 999999999;
		int ans = 0;
		
		while (T < N) {
			for (int i = 0; i < N;i ++ ){
				if(i < T){
					ans_a = ans_a + ls4.get(i);
				}else{
					ans_b = ans_b + ls4.get(i);
				}
			}
			if(min > Math.abs(ans_a - ans_b)){
				min = Math.abs(ans_a - ans_b);
				ans = T;
			}
			T ++;
			ans_a = 0;
			ans_b = 0;
		}
	    
		System.out.println(min);

   		sc.close();
        return ;

    } main {
    	
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();

		ArrayList<Integer> ls4 = new ArrayList<Integer>();

		for (int i = 0; i < N;i ++ ){
			// 重りを入力
			ls4.add( sc.nextInt());
		}

		int ans_a = 0;
		int ans_b = 0;//合計
		int T = 0;
		int min = 999999999;
		int ans = 0;
		
		while (T < N) {
			for (int i = 0; i < N;i ++ ){
				if(i < T){
					ans_a = ans_a + ls4.get(i);
				}else{
					ans_b = ans_b + ls4.get(i);
				}
			}
			if(min > Math.abs(ans_a - ans_b)){
				min = Math.abs(ans_a - ans_b);
				ans = T;
			}
			T ++;
			ans_a = 0;
			ans_b = 0;
		}
	    
		System.out.println(min);

   		sc.close();
        return ;

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc ArrayList<Integer> ls4 = new ArrayList<Integer>(); ls4 new ArrayList<Integer>() for (int i = 0; i < N;i ++ ){
			// 重りを入力
			ls4.add( sc.nextInt());
		} int i = 0; int i = 0; i 0 i < N i N i ++ i ++ i {
			// 重りを入力
			ls4.add( sc.nextInt());
		} {
			// 重りを入力
			ls4.add( sc.nextInt());
		} ls4.add( sc.nextInt()) ls4.add ls4 sc.nextInt() sc.nextInt sc int ans_a = 0; ans_a 0 int ans_b = 0; ans_b 0 int T = 0; T 0 int min = 999999999; min 999999999 int ans = 0; ans 0 while (T < N) {
			for (int i = 0; i < N;i ++ ){
				if(i < T){
					ans_a = ans_a + ls4.get(i);
				}else{
					ans_b = ans_b + ls4.get(i);
				}
			}
			if(min > Math.abs(ans_a - ans_b)){
				min = Math.abs(ans_a - ans_b);
				ans = T;
			}
			T ++;
			ans_a = 0;
			ans_b = 0;
		} T < N T N {
			for (int i = 0; i < N;i ++ ){
				if(i < T){
					ans_a = ans_a + ls4.get(i);
				}else{
					ans_b = ans_b + ls4.get(i);
				}
			}
			if(min > Math.abs(ans_a - ans_b)){
				min = Math.abs(ans_a - ans_b);
				ans = T;
			}
			T ++;
			ans_a = 0;
			ans_b = 0;
		} for (int i = 0; i < N;i ++ ){
				if(i < T){
					ans_a = ans_a + ls4.get(i);
				}else{
					ans_b = ans_b + ls4.get(i);
				}
			} int i = 0; int i = 0; i 0 i < N i N i ++ i ++ i {
				if(i < T){
					ans_a = ans_a + ls4.get(i);
				}else{
					ans_b = ans_b + ls4.get(i);
				}
			} {
				if(i < T){
					ans_a = ans_a + ls4.get(i);
				}else{
					ans_b = ans_b + ls4.get(i);
				}
			} if(i < T){
					ans_a = ans_a + ls4.get(i);
				}else{
					ans_b = ans_b + ls4.get(i);
				} i < T i T {
					ans_a = ans_a + ls4.get(i);
				} ans_a = ans_a + ls4.get(i) ans_a ans_a + ls4.get(i) ans_a ls4.get(i) ls4.get ls4 i {
					ans_b = ans_b + ls4.get(i);
				} ans_b = ans_b + ls4.get(i) ans_b ans_b + ls4.get(i) ans_b ls4.get(i) ls4.get ls4 i if(min > Math.abs(ans_a - ans_b)){
				min = Math.abs(ans_a - ans_b);
				ans = T;
			} min > Math.abs(ans_a - ans_b) min Math.abs(ans_a - ans_b) Math.abs Math ans_a - ans_b ans_a ans_b {
				min = Math.abs(ans_a - ans_b);
				ans = T;
			} min = Math.abs(ans_a - ans_b) min Math.abs(ans_a - ans_b) Math.abs Math ans_a - ans_b ans_a ans_b ans = T ans T T ++ T ans_a = 0 ans_a 0 ans_b = 0 ans_b 0 System.out.println(min) System.out.println System.out System System.out min sc.close() sc.close sc return ; String[] args args public class Main {

    public static void main(String[] args) {
    	
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();

		ArrayList<Integer> ls4 = new ArrayList<Integer>();

		for (int i = 0; i < N;i ++ ){
			// 重りを入力
			ls4.add( sc.nextInt());
		}

		int ans_a = 0;
		int ans_b = 0;//合計
		int T = 0;
		int min = 999999999;
		int ans = 0;
		
		while (T < N) {
			for (int i = 0; i < N;i ++ ){
				if(i < T){
					ans_a = ans_a + ls4.get(i);
				}else{
					ans_b = ans_b + ls4.get(i);
				}
			}
			if(min > Math.abs(ans_a - ans_b)){
				min = Math.abs(ans_a - ans_b);
				ans = T;
			}
			T ++;
			ans_a = 0;
			ans_b = 0;
		}
	    
		System.out.println(min);

   		sc.close();
        return ;

    }
    
} public class Main {

    public static void main(String[] args) {
    	
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();

		ArrayList<Integer> ls4 = new ArrayList<Integer>();

		for (int i = 0; i < N;i ++ ){
			// 重りを入力
			ls4.add( sc.nextInt());
		}

		int ans_a = 0;
		int ans_b = 0;//合計
		int T = 0;
		int min = 999999999;
		int ans = 0;
		
		while (T < N) {
			for (int i = 0; i < N;i ++ ){
				if(i < T){
					ans_a = ans_a + ls4.get(i);
				}else{
					ans_b = ans_b + ls4.get(i);
				}
			}
			if(min > Math.abs(ans_a - ans_b)){
				min = Math.abs(ans_a - ans_b);
				ans = T;
			}
			T ++;
			ans_a = 0;
			ans_b = 0;
		}
	    
		System.out.println(min);

   		sc.close();
        return ;

    }
    
} Main
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    	
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();

		ArrayList<Integer> ls4 = new ArrayList<Integer>();

		for (int i = 0; i < N;i ++ ){
			// 重りを入力
			ls4.add( sc.nextInt());
		}

		int ans_a = 0;
		int ans_b = 0;//合計
		int T = 0;
		int min = 999999999;
		int ans = 0;
		
		while (T < N) {
			for (int i = 0; i < N;i ++ ){
				if(i < T){
					ans_a = ans_a + ls4.get(i);
				}else{
					ans_b = ans_b + ls4.get(i);
				}
			}
			if(min > Math.abs(ans_a - ans_b)){
				min = Math.abs(ans_a - ans_b);
				ans = T;
			}
			T ++;
			ans_a = 0;
			ans_b = 0;
		}
	    
		System.out.println(min);

   		sc.close();
        return ;

    }
    
}

