import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] w = new int[n];
        int s1 = 0;
        int s2 = 0;
        for(int i = 0; i < n; i++){
            w[i] = Integer.parseInt(sc.next());
            s2 += w[i];
        }
        
        int min = 10000;
        int abs;
        for(int i = 0; i < n-1; i++){
            s1 += w[i];
            s2 -= w[i];
            abs = Math.abs(s1 - s2);
            if(abs < min){
                min = abs;
            }
        }
        
        System.out.println(min);
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] w = new int[n];
        int s1 = 0;
        int s2 = 0;
        for(int i = 0; i < n; i++){
            w[i] = Integer.parseInt(sc.next());
            s2 += w[i];
        }
        
        int min = 10000;
        int abs;
        for(int i = 0; i < n-1; i++){
            s1 += w[i];
            s2 -= w[i];
            abs = Math.abs(s1 - s2);
            if(abs < min){
                min = abs;
            }
        }
        
        System.out.println(min);
    }
} Main public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] w = new int[n];
        int s1 = 0;
        int s2 = 0;
        for(int i = 0; i < n; i++){
            w[i] = Integer.parseInt(sc.next());
            s2 += w[i];
        }
        
        int min = 10000;
        int abs;
        for(int i = 0; i < n-1; i++){
            s1 += w[i];
            s2 -= w[i];
            abs = Math.abs(s1 - s2);
            if(abs < min){
                min = abs;
            }
        }
        
        System.out.println(min);
    } main {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] w = new int[n];
        int s1 = 0;
        int s2 = 0;
        for(int i = 0; i < n; i++){
            w[i] = Integer.parseInt(sc.next());
            s2 += w[i];
        }
        
        int min = 10000;
        int abs;
        for(int i = 0; i < n-1; i++){
            s1 += w[i];
            s2 -= w[i];
            abs = Math.abs(s1 - s2);
            if(abs < min){
                min = abs;
            }
        }
        
        System.out.println(min);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int[] w = new int[n]; w new int[n] n int s1 = 0; s1 0 int s2 = 0; s2 0 for(int i = 0; i < n; i++){
            w[i] = Integer.parseInt(sc.next());
            s2 += w[i];
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            w[i] = Integer.parseInt(sc.next());
            s2 += w[i];
        } {
            w[i] = Integer.parseInt(sc.next());
            s2 += w[i];
        } w[i] = Integer.parseInt(sc.next()) w[i] w i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc s2 += w[i] s2 w[i] w i int min = 10000; min 10000 int abs; abs for(int i = 0; i < n-1; i++){
            s1 += w[i];
            s2 -= w[i];
            abs = Math.abs(s1 - s2);
            if(abs < min){
                min = abs;
            }
        } int i = 0; int i = 0; i 0 i < n-1 i n-1 n 1 i++ i++ i {
            s1 += w[i];
            s2 -= w[i];
            abs = Math.abs(s1 - s2);
            if(abs < min){
                min = abs;
            }
        } {
            s1 += w[i];
            s2 -= w[i];
            abs = Math.abs(s1 - s2);
            if(abs < min){
                min = abs;
            }
        } s1 += w[i] s1 w[i] w i s2 -= w[i] s2 w[i] w i abs = Math.abs(s1 - s2) abs Math.abs(s1 - s2) Math.abs Math s1 - s2 s1 s2 if(abs < min){
                min = abs;
            } abs < min abs min {
                min = abs;
            } min = abs min abs 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 = Integer.parseInt(sc.next());
        int[] w = new int[n];
        int s1 = 0;
        int s2 = 0;
        for(int i = 0; i < n; i++){
            w[i] = Integer.parseInt(sc.next());
            s2 += w[i];
        }
        
        int min = 10000;
        int abs;
        for(int i = 0; i < n-1; i++){
            s1 += w[i];
            s2 -= w[i];
            abs = Math.abs(s1 - s2);
            if(abs < min){
                min = abs;
            }
        }
        
        System.out.println(min);
    }
} public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] w = new int[n];
        int s1 = 0;
        int s2 = 0;
        for(int i = 0; i < n; i++){
            w[i] = Integer.parseInt(sc.next());
            s2 += w[i];
        }
        
        int min = 10000;
        int abs;
        for(int i = 0; i < n-1; i++){
            s1 += w[i];
            s2 -= w[i];
            abs = Math.abs(s1 - s2);
            if(abs < min){
                min = abs;
            }
        }
        
        System.out.println(min);
    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] w = new int[n];
        int s1 = 0;
        int s2 = 0;
        for(int i = 0; i < n; i++){
            w[i] = Integer.parseInt(sc.next());
            s2 += w[i];
        }
        
        int min = 10000;
        int abs;
        for(int i = 0; i < n-1; i++){
            s1 += w[i];
            s2 -= w[i];
            abs = Math.abs(s1 - s2);
            if(abs < min){
                min = abs;
            }
        }
        
        System.out.println(min);
    }
}