import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[] W = new int[N];
        for (int i = 0; i < N; i++)
            W[i] = sc.nextInt();
        
        int sum = 0;

        for(int i = 0; i < N; i++)
            sum += W[i];
        
        int ans = sum;
        
        for(int i = 0; i < N; i++){
            int sum_i = sum_t(W, i);
            if(Math.abs((sum_i)-(sum-sum_i)) < ans)
                ans = Math.abs((sum_i)-(sum-sum_i));
        }
        System.out.println(ans);
        sc.close();
    }
    
    static int sum_t(int[] a, int t){
        int sum = 0;
        for(int i = 0; i < t; i++)
            sum += a[i];
        return sum;
    }
} 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[] W = new int[N];
        for (int i = 0; i < N; i++)
            W[i] = sc.nextInt();
        
        int sum = 0;

        for(int i = 0; i < N; i++)
            sum += W[i];
        
        int ans = sum;
        
        for(int i = 0; i < N; i++){
            int sum_i = sum_t(W, i);
            if(Math.abs((sum_i)-(sum-sum_i)) < ans)
                ans = Math.abs((sum_i)-(sum-sum_i));
        }
        System.out.println(ans);
        sc.close();
    }
    
    static int sum_t(int[] a, int t){
        int sum = 0;
        for(int i = 0; i < t; i++)
            sum += a[i];
        return sum;
    }
} Main public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[] W = new int[N];
        for (int i = 0; i < N; i++)
            W[i] = sc.nextInt();
        
        int sum = 0;

        for(int i = 0; i < N; i++)
            sum += W[i];
        
        int ans = sum;
        
        for(int i = 0; i < N; i++){
            int sum_i = sum_t(W, i);
            if(Math.abs((sum_i)-(sum-sum_i)) < ans)
                ans = Math.abs((sum_i)-(sum-sum_i));
        }
        System.out.println(ans);
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[] W = new int[N];
        for (int i = 0; i < N; i++)
            W[i] = sc.nextInt();
        
        int sum = 0;

        for(int i = 0; i < N; i++)
            sum += W[i];
        
        int ans = sum;
        
        for(int i = 0; i < N; i++){
            int sum_i = sum_t(W, i);
            if(Math.abs((sum_i)-(sum-sum_i)) < ans)
                ans = Math.abs((sum_i)-(sum-sum_i));
        }
        System.out.println(ans);
        sc.close();
    } 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 for (int i = 0; i < N; i++)
            W[i] = sc.nextInt(); int i = 0; int i = 0; i 0 i < N i N i++ i++ i W[i] = sc.nextInt(); W[i] = sc.nextInt() W[i] W i sc.nextInt() sc.nextInt sc int sum = 0; sum 0 for(int i = 0; i < N; i++)
            sum += W[i]; int i = 0; int i = 0; i 0 i < N i N i++ i++ i sum += W[i]; sum += W[i] sum W[i] W i int ans = sum; ans sum for(int i = 0; i < N; i++){
            int sum_i = sum_t(W, i);
            if(Math.abs((sum_i)-(sum-sum_i)) < ans)
                ans = Math.abs((sum_i)-(sum-sum_i));
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            int sum_i = sum_t(W, i);
            if(Math.abs((sum_i)-(sum-sum_i)) < ans)
                ans = Math.abs((sum_i)-(sum-sum_i));
        } {
            int sum_i = sum_t(W, i);
            if(Math.abs((sum_i)-(sum-sum_i)) < ans)
                ans = Math.abs((sum_i)-(sum-sum_i));
        } int sum_i = sum_t(W, i); sum_i sum_t(W, i) sum_t W i if(Math.abs((sum_i)-(sum-sum_i)) < ans)
                ans = Math.abs((sum_i)-(sum-sum_i)); Math.abs((sum_i)-(sum-sum_i)) < ans Math.abs((sum_i)-(sum-sum_i)) Math.abs Math (sum_i)-(sum-sum_i) (sum_i) (sum-sum_i) sum sum_i ans ans = Math.abs((sum_i)-(sum-sum_i)) ans Math.abs((sum_i)-(sum-sum_i)) Math.abs Math (sum_i)-(sum-sum_i) (sum_i) (sum-sum_i) sum sum_i System.out.println(ans) System.out.println System.out System System.out ans sc.close() sc.close sc String args[] args static int sum_t(int[] a, int t){
        int sum = 0;
        for(int i = 0; i < t; i++)
            sum += a[i];
        return sum;
    } sum_t {
        int sum = 0;
        for(int i = 0; i < t; i++)
            sum += a[i];
        return sum;
    } int sum = 0; sum 0 for(int i = 0; i < t; i++)
            sum += a[i]; int i = 0; int i = 0; i 0 i < t i t i++ i++ i sum += a[i]; sum += a[i] sum a[i] a i return sum; sum int[] a a int t t public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[] W = new int[N];
        for (int i = 0; i < N; i++)
            W[i] = sc.nextInt();
        
        int sum = 0;

        for(int i = 0; i < N; i++)
            sum += W[i];
        
        int ans = sum;
        
        for(int i = 0; i < N; i++){
            int sum_i = sum_t(W, i);
            if(Math.abs((sum_i)-(sum-sum_i)) < ans)
                ans = Math.abs((sum_i)-(sum-sum_i));
        }
        System.out.println(ans);
        sc.close();
    }
    
    static int sum_t(int[] a, int t){
        int sum = 0;
        for(int i = 0; i < t; i++)
            sum += a[i];
        return sum;
    }
} public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[] W = new int[N];
        for (int i = 0; i < N; i++)
            W[i] = sc.nextInt();
        
        int sum = 0;

        for(int i = 0; i < N; i++)
            sum += W[i];
        
        int ans = sum;
        
        for(int i = 0; i < N; i++){
            int sum_i = sum_t(W, i);
            if(Math.abs((sum_i)-(sum-sum_i)) < ans)
                ans = Math.abs((sum_i)-(sum-sum_i));
        }
        System.out.println(ans);
        sc.close();
    }
    
    static int sum_t(int[] a, int t){
        int sum = 0;
        for(int i = 0; i < t; i++)
            sum += a[i];
        return sum;
    }
} Main
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[] W = new int[N];
        for (int i = 0; i < N; i++)
            W[i] = sc.nextInt();
        
        int sum = 0;

        for(int i = 0; i < N; i++)
            sum += W[i];
        
        int ans = sum;
        
        for(int i = 0; i < N; i++){
            int sum_i = sum_t(W, i);
            if(Math.abs((sum_i)-(sum-sum_i)) < ans)
                ans = Math.abs((sum_i)-(sum-sum_i));
        }
        System.out.println(ans);
        sc.close();
    }
    
    static int sum_t(int[] a, int t){
        int sum = 0;
        for(int i = 0; i < t; i++)
            sum += a[i];
        return sum;
    }
}