import java.util.*;
import java.lang.Object;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] weight = new int[n];
        int g1 = 0;
        int sum = 0;
        int sabun = 222222;
        int min = 222222;
        int g2 = 0;

        for(int i = 0;i<n;i++){
            weight[i] = sc.nextInt();
            sum +=weight[i];
        }

        for(int i = 0;i<n;i++){
            for(int j =0;j<=i;j++){
                g1+=weight[j];
            }
            //System.out.println("g1: "+g1);
             g2 = sum - g1;
             sabun = Math.abs(g2-g1);
            if(min>sabun){
                min = sabun;
                
            }
            g1=0;
        }
            System.out.println(min);


    }
} import java.util.*; util.* java import java.lang.Object; Object java.lang public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] weight = new int[n];
        int g1 = 0;
        int sum = 0;
        int sabun = 222222;
        int min = 222222;
        int g2 = 0;

        for(int i = 0;i<n;i++){
            weight[i] = sc.nextInt();
            sum +=weight[i];
        }

        for(int i = 0;i<n;i++){
            for(int j =0;j<=i;j++){
                g1+=weight[j];
            }
            //System.out.println("g1: "+g1);
             g2 = sum - g1;
             sabun = Math.abs(g2-g1);
            if(min>sabun){
                min = sabun;
                
            }
            g1=0;
        }
            System.out.println(min);


    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] weight = new int[n];
        int g1 = 0;
        int sum = 0;
        int sabun = 222222;
        int min = 222222;
        int g2 = 0;

        for(int i = 0;i<n;i++){
            weight[i] = sc.nextInt();
            sum +=weight[i];
        }

        for(int i = 0;i<n;i++){
            for(int j =0;j<=i;j++){
                g1+=weight[j];
            }
            //System.out.println("g1: "+g1);
             g2 = sum - g1;
             sabun = Math.abs(g2-g1);
            if(min>sabun){
                min = sabun;
                
            }
            g1=0;
        }
            System.out.println(min);


    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] weight = new int[n];
        int g1 = 0;
        int sum = 0;
        int sabun = 222222;
        int min = 222222;
        int g2 = 0;

        for(int i = 0;i<n;i++){
            weight[i] = sc.nextInt();
            sum +=weight[i];
        }

        for(int i = 0;i<n;i++){
            for(int j =0;j<=i;j++){
                g1+=weight[j];
            }
            //System.out.println("g1: "+g1);
             g2 = sum - g1;
             sabun = Math.abs(g2-g1);
            if(min>sabun){
                min = sabun;
                
            }
            g1=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 int[] weight = new int[n]; weight new int[n] n int g1 = 0; g1 0 int sum = 0; sum 0 int sabun = 222222; sabun 222222 int min = 222222; min 222222 int g2 = 0; g2 0 for(int i = 0;i<n;i++){
            weight[i] = sc.nextInt();
            sum +=weight[i];
        } int i = 0; int i = 0; i 0 i<n i n i++ i++ i {
            weight[i] = sc.nextInt();
            sum +=weight[i];
        } {
            weight[i] = sc.nextInt();
            sum +=weight[i];
        } weight[i] = sc.nextInt() weight[i] weight i sc.nextInt() sc.nextInt sc sum +=weight[i] sum weight[i] weight i for(int i = 0;i<n;i++){
            for(int j =0;j<=i;j++){
                g1+=weight[j];
            }
            //System.out.println("g1: "+g1);
             g2 = sum - g1;
             sabun = Math.abs(g2-g1);
            if(min>sabun){
                min = sabun;
                
            }
            g1=0;
        } int i = 0; int i = 0; i 0 i<n i n i++ i++ i {
            for(int j =0;j<=i;j++){
                g1+=weight[j];
            }
            //System.out.println("g1: "+g1);
             g2 = sum - g1;
             sabun = Math.abs(g2-g1);
            if(min>sabun){
                min = sabun;
                
            }
            g1=0;
        } {
            for(int j =0;j<=i;j++){
                g1+=weight[j];
            }
            //System.out.println("g1: "+g1);
             g2 = sum - g1;
             sabun = Math.abs(g2-g1);
            if(min>sabun){
                min = sabun;
                
            }
            g1=0;
        } for(int j =0;j<=i;j++){
                g1+=weight[j];
            } int j =0; int j =0; j 0 j<=i j i j++ j++ j {
                g1+=weight[j];
            } {
                g1+=weight[j];
            } g1+=weight[j] g1 weight[j] weight j g2 = sum - g1 g2 sum - g1 sum g1 sabun = Math.abs(g2-g1) sabun Math.abs(g2-g1) Math.abs Math g2-g1 g2 g1 if(min>sabun){
                min = sabun;
                
            } min>sabun min sabun {
                min = sabun;
                
            } min = sabun min sabun g1=0 g1 0 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 n = sc.nextInt();
        int[] weight = new int[n];
        int g1 = 0;
        int sum = 0;
        int sabun = 222222;
        int min = 222222;
        int g2 = 0;

        for(int i = 0;i<n;i++){
            weight[i] = sc.nextInt();
            sum +=weight[i];
        }

        for(int i = 0;i<n;i++){
            for(int j =0;j<=i;j++){
                g1+=weight[j];
            }
            //System.out.println("g1: "+g1);
             g2 = sum - g1;
             sabun = Math.abs(g2-g1);
            if(min>sabun){
                min = sabun;
                
            }
            g1=0;
        }
            System.out.println(min);


    }
} public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] weight = new int[n];
        int g1 = 0;
        int sum = 0;
        int sabun = 222222;
        int min = 222222;
        int g2 = 0;

        for(int i = 0;i<n;i++){
            weight[i] = sc.nextInt();
            sum +=weight[i];
        }

        for(int i = 0;i<n;i++){
            for(int j =0;j<=i;j++){
                g1+=weight[j];
            }
            //System.out.println("g1: "+g1);
             g2 = sum - g1;
             sabun = Math.abs(g2-g1);
            if(min>sabun){
                min = sabun;
                
            }
            g1=0;
        }
            System.out.println(min);


    }
} Main
import java.util.*;
import java.lang.Object;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] weight = new int[n];
        int g1 = 0;
        int sum = 0;
        int sabun = 222222;
        int min = 222222;
        int g2 = 0;

        for(int i = 0;i<n;i++){
            weight[i] = sc.nextInt();
            sum +=weight[i];
        }

        for(int i = 0;i<n;i++){
            for(int j =0;j<=i;j++){
                g1+=weight[j];
            }
            //System.out.println("g1: "+g1);
             g2 = sum - g1;
             sabun = Math.abs(g2-g1);
            if(min>sabun){
                min = sabun;
                
            }
            g1=0;
        }
            System.out.println(min);


    }
}
