import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] Weight = new int[n];
        for(int i = 0; i < n; i++){
            Weight[i] = sc.nextInt();
        }
        int sum = 0;
        for(int i = 0; i < n; i++){
            sum = sum + Weight[i];
        }
        int subsum = 0;
        int sub = 0;
        int submin = sum;
        for(int i = 0; i < n; i++){
            subsum = subsum + Weight[i];
            sub = Math.abs((sum - subsum) - subsum);
            if(sub < submin){
                submin = sub;
            }
        }
        System.out.print(submin);
    }
} import java.util.*; util.* java public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] Weight = new int[n];
        for(int i = 0; i < n; i++){
            Weight[i] = sc.nextInt();
        }
        int sum = 0;
        for(int i = 0; i < n; i++){
            sum = sum + Weight[i];
        }
        int subsum = 0;
        int sub = 0;
        int submin = sum;
        for(int i = 0; i < n; i++){
            subsum = subsum + Weight[i];
            sub = Math.abs((sum - subsum) - subsum);
            if(sub < submin){
                submin = sub;
            }
        }
        System.out.print(submin);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] Weight = new int[n];
        for(int i = 0; i < n; i++){
            Weight[i] = sc.nextInt();
        }
        int sum = 0;
        for(int i = 0; i < n; i++){
            sum = sum + Weight[i];
        }
        int subsum = 0;
        int sub = 0;
        int submin = sum;
        for(int i = 0; i < n; i++){
            subsum = subsum + Weight[i];
            sub = Math.abs((sum - subsum) - subsum);
            if(sub < submin){
                submin = sub;
            }
        }
        System.out.print(submin);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] Weight = new int[n];
        for(int i = 0; i < n; i++){
            Weight[i] = sc.nextInt();
        }
        int sum = 0;
        for(int i = 0; i < n; i++){
            sum = sum + Weight[i];
        }
        int subsum = 0;
        int sub = 0;
        int submin = sum;
        for(int i = 0; i < n; i++){
            subsum = subsum + Weight[i];
            sub = Math.abs((sum - subsum) - subsum);
            if(sub < submin){
                submin = sub;
            }
        }
        System.out.print(submin);
    } 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 for(int i = 0; i < n; i++){
            Weight[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            Weight[i] = sc.nextInt();
        } {
            Weight[i] = sc.nextInt();
        } Weight[i] = sc.nextInt() Weight[i] Weight i sc.nextInt() sc.nextInt sc int sum = 0; sum 0 for(int i = 0; i < n; i++){
            sum = sum + Weight[i];
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            sum = sum + Weight[i];
        } {
            sum = sum + Weight[i];
        } sum = sum + Weight[i] sum sum + Weight[i] sum Weight[i] Weight i int subsum = 0; subsum 0 int sub = 0; sub 0 int submin = sum; submin sum for(int i = 0; i < n; i++){
            subsum = subsum + Weight[i];
            sub = Math.abs((sum - subsum) - subsum);
            if(sub < submin){
                submin = sub;
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            subsum = subsum + Weight[i];
            sub = Math.abs((sum - subsum) - subsum);
            if(sub < submin){
                submin = sub;
            }
        } {
            subsum = subsum + Weight[i];
            sub = Math.abs((sum - subsum) - subsum);
            if(sub < submin){
                submin = sub;
            }
        } subsum = subsum + Weight[i] subsum subsum + Weight[i] subsum Weight[i] Weight i sub = Math.abs((sum - subsum) - subsum) sub Math.abs((sum - subsum) - subsum) Math.abs Math (sum - subsum) - subsum (sum - subsum) sum subsum subsum if(sub < submin){
                submin = sub;
            } sub < submin sub submin {
                submin = sub;
            } submin = sub submin sub System.out.print(submin) System.out.print System.out System System.out submin 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];
        for(int i = 0; i < n; i++){
            Weight[i] = sc.nextInt();
        }
        int sum = 0;
        for(int i = 0; i < n; i++){
            sum = sum + Weight[i];
        }
        int subsum = 0;
        int sub = 0;
        int submin = sum;
        for(int i = 0; i < n; i++){
            subsum = subsum + Weight[i];
            sub = Math.abs((sum - subsum) - subsum);
            if(sub < submin){
                submin = sub;
            }
        }
        System.out.print(submin);
    }
} public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] Weight = new int[n];
        for(int i = 0; i < n; i++){
            Weight[i] = sc.nextInt();
        }
        int sum = 0;
        for(int i = 0; i < n; i++){
            sum = sum + Weight[i];
        }
        int subsum = 0;
        int sub = 0;
        int submin = sum;
        for(int i = 0; i < n; i++){
            subsum = subsum + Weight[i];
            sub = Math.abs((sum - subsum) - subsum);
            if(sub < submin){
                submin = sub;
            }
        }
        System.out.print(submin);
    }
} Main
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] Weight = new int[n];
        for(int i = 0; i < n; i++){
            Weight[i] = sc.nextInt();
        }
        int sum = 0;
        for(int i = 0; i < n; i++){
            sum = sum + Weight[i];
        }
        int subsum = 0;
        int sub = 0;
        int submin = sum;
        for(int i = 0; i < n; i++){
            subsum = subsum + Weight[i];
            sub = Math.abs((sum - subsum) - subsum);
            if(sub < submin){
                submin = sub;
            }
        }
        System.out.print(submin);
    }
}