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 min = Integer.MAX_VALUE;
        
        for(int i = 0; i < n-1; i++){ //何個目を指定するか
            int l = 0; //左の総和
            int r = 0; //右の総和
            
            for(int j = i; j >= 0; j--){ //左
                l+=w[j];
            }
            
            for(int j = i+1; j < n; j++){ //右
                r+=w[j];
            }
            
            min = Math.min(min, Math.abs(l - r));
        }
        
        System.out.println(min);
    }
} 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 min = Integer.MAX_VALUE;
        
        for(int i = 0; i < n-1; i++){ //何個目を指定するか
            int l = 0; //左の総和
            int r = 0; //右の総和
            
            for(int j = i; j >= 0; j--){ //左
                l+=w[j];
            }
            
            for(int j = i+1; j < n; j++){ //右
                r+=w[j];
            }
            
            min = Math.min(min, Math.abs(l - r));
        }
        
        System.out.println(min);
    }
} 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 min = Integer.MAX_VALUE;
        
        for(int i = 0; i < n-1; i++){ //何個目を指定するか
            int l = 0; //左の総和
            int r = 0; //右の総和
            
            for(int j = i; j >= 0; j--){ //左
                l+=w[j];
            }
            
            for(int j = i+1; j < n; j++){ //右
                r+=w[j];
            }
            
            min = Math.min(min, Math.abs(l - r));
        }
        
        System.out.println(min);
    } 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 min = Integer.MAX_VALUE;
        
        for(int i = 0; i < n-1; i++){ //何個目を指定するか
            int l = 0; //左の総和
            int r = 0; //右の総和
            
            for(int j = i; j >= 0; j--){ //左
                l+=w[j];
            }
            
            for(int j = i+1; j < n; j++){ //右
                r+=w[j];
            }
            
            min = Math.min(min, Math.abs(l - r));
        }
        
        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[] 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 min = Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE for(int i = 0; i < n-1; i++){ //何個目を指定するか
            int l = 0; //左の総和
            int r = 0; //右の総和
            
            for(int j = i; j >= 0; j--){ //左
                l+=w[j];
            }
            
            for(int j = i+1; j < n; j++){ //右
                r+=w[j];
            }
            
            min = Math.min(min, Math.abs(l - r));
        } int i = 0; int i = 0; i 0 i < n-1 i n-1 n 1 i++ i++ i { //何個目を指定するか
            int l = 0; //左の総和
            int r = 0; //右の総和
            
            for(int j = i; j >= 0; j--){ //左
                l+=w[j];
            }
            
            for(int j = i+1; j < n; j++){ //右
                r+=w[j];
            }
            
            min = Math.min(min, Math.abs(l - r));
        } { //何個目を指定するか
            int l = 0; //左の総和
            int r = 0; //右の総和
            
            for(int j = i; j >= 0; j--){ //左
                l+=w[j];
            }
            
            for(int j = i+1; j < n; j++){ //右
                r+=w[j];
            }
            
            min = Math.min(min, Math.abs(l - r));
        } int l = 0; l 0 int r = 0; r 0 for(int j = i; j >= 0; j--){ //左
                l+=w[j];
            } int j = i; int j = i; j i j >= 0 j 0 j-- j-- j { //左
                l+=w[j];
            } { //左
                l+=w[j];
            } l+=w[j] l w[j] w j for(int j = i+1; j < n; j++){ //右
                r+=w[j];
            } int j = i+1; int j = i+1; j i+1 i 1 j < n j n j++ j++ j { //右
                r+=w[j];
            } { //右
                r+=w[j];
            } r+=w[j] r w[j] w j min = Math.min(min, Math.abs(l - r)) min Math.min(min, Math.abs(l - r)) Math.min Math min Math.abs(l - r) Math.abs Math l - r l r 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[] w = new int[n];
        
        for(int i = 0; i < n; i++) w[i] = sc.nextInt();
        
        int min = Integer.MAX_VALUE;
        
        for(int i = 0; i < n-1; i++){ //何個目を指定するか
            int l = 0; //左の総和
            int r = 0; //右の総和
            
            for(int j = i; j >= 0; j--){ //左
                l+=w[j];
            }
            
            for(int j = i+1; j < n; j++){ //右
                r+=w[j];
            }
            
            min = Math.min(min, Math.abs(l - r));
        }
        
        System.out.println(min);
    }
} 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 min = Integer.MAX_VALUE;
        
        for(int i = 0; i < n-1; i++){ //何個目を指定するか
            int l = 0; //左の総和
            int r = 0; //右の総和
            
            for(int j = i; j >= 0; j--){ //左
                l+=w[j];
            }
            
            for(int j = i+1; j < n; j++){ //右
                r+=w[j];
            }
            
            min = Math.min(min, Math.abs(l - r));
        }
        
        System.out.println(min);
    }
} 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 min = Integer.MAX_VALUE;
        
        for(int i = 0; i < n-1; i++){ //何個目を指定するか
            int l = 0; //左の総和
            int r = 0; //右の総和
            
            for(int j = i; j >= 0; j--){ //左
                l+=w[j];
            }
            
            for(int j = i+1; j < n; j++){ //右
                r+=w[j];
            }
            
            min = Math.min(min, Math.abs(l - r));
        }
        
        System.out.println(min);
    }
}
