import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.List;

public class Main {
    public static void main(String args[]) throws IOException {
        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();
            if (i>0){
                w[i]+=w[i-1];
            }
        }
        int min=Integer.MAX_VALUE;
        for (int i=1;i<n;i++){
            if (Math.abs(w[i-1]-(w[n-1]-w[i-1]))<min){
                min=Math.abs(w[i-1]-(w[n-1]-w[i-1]));
            }
        }
        System.out.println(min);
    }


}
 import java.awt.*; awt.* java import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.*; util.* java import java.util.List; List java.util public class Main {
    public static void main(String args[]) throws IOException {
        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();
            if (i>0){
                w[i]+=w[i-1];
            }
        }
        int min=Integer.MAX_VALUE;
        for (int i=1;i<n;i++){
            if (Math.abs(w[i-1]-(w[n-1]-w[i-1]))<min){
                min=Math.abs(w[i-1]-(w[n-1]-w[i-1]));
            }
        }
        System.out.println(min);
    }


} Main public static void main(String args[]) throws IOException {
        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();
            if (i>0){
                w[i]+=w[i-1];
            }
        }
        int min=Integer.MAX_VALUE;
        for (int i=1;i<n;i++){
            if (Math.abs(w[i-1]-(w[n-1]-w[i-1]))<min){
                min=Math.abs(w[i-1]-(w[n-1]-w[i-1]));
            }
        }
        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();
            if (i>0){
                w[i]+=w[i-1];
            }
        }
        int min=Integer.MAX_VALUE;
        for (int i=1;i<n;i++){
            if (Math.abs(w[i-1]-(w[n-1]-w[i-1]))<min){
                min=Math.abs(w[i-1]-(w[n-1]-w[i-1]));
            }
        }
        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();
            if (i>0){
                w[i]+=w[i-1];
            }
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            w[i]=sc.nextInt();
            if (i>0){
                w[i]+=w[i-1];
            }
        } {
            w[i]=sc.nextInt();
            if (i>0){
                w[i]+=w[i-1];
            }
        } w[i]=sc.nextInt() w[i] w i sc.nextInt() sc.nextInt sc if (i>0){
                w[i]+=w[i-1];
            } i>0 i 0 {
                w[i]+=w[i-1];
            } w[i]+=w[i-1] w[i] w i w[i-1] w i-1 i 1 int min=Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int i=1;i<n;i++){
            if (Math.abs(w[i-1]-(w[n-1]-w[i-1]))<min){
                min=Math.abs(w[i-1]-(w[n-1]-w[i-1]));
            }
        } int i=1; int i=1; i 1 i<n i n i++ i++ i {
            if (Math.abs(w[i-1]-(w[n-1]-w[i-1]))<min){
                min=Math.abs(w[i-1]-(w[n-1]-w[i-1]));
            }
        } {
            if (Math.abs(w[i-1]-(w[n-1]-w[i-1]))<min){
                min=Math.abs(w[i-1]-(w[n-1]-w[i-1]));
            }
        } if (Math.abs(w[i-1]-(w[n-1]-w[i-1]))<min){
                min=Math.abs(w[i-1]-(w[n-1]-w[i-1]));
            } Math.abs(w[i-1]-(w[n-1]-w[i-1]))<min Math.abs(w[i-1]-(w[n-1]-w[i-1])) Math.abs Math w[i-1]-(w[n-1]-w[i-1]) w[i-1] w i-1 i 1 (w[n-1]-w[i-1]) w[n-1] w n-1 n 1 w[i-1] w i-1 i 1 min {
                min=Math.abs(w[i-1]-(w[n-1]-w[i-1]));
            } min=Math.abs(w[i-1]-(w[n-1]-w[i-1])) min Math.abs(w[i-1]-(w[n-1]-w[i-1])) Math.abs Math w[i-1]-(w[n-1]-w[i-1]) w[i-1] w i-1 i 1 (w[n-1]-w[i-1]) w[n-1] w n-1 n 1 w[i-1] w i-1 i 1 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[]) throws IOException {
        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();
            if (i>0){
                w[i]+=w[i-1];
            }
        }
        int min=Integer.MAX_VALUE;
        for (int i=1;i<n;i++){
            if (Math.abs(w[i-1]-(w[n-1]-w[i-1]))<min){
                min=Math.abs(w[i-1]-(w[n-1]-w[i-1]));
            }
        }
        System.out.println(min);
    }


} public class Main {
    public static void main(String args[]) throws IOException {
        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();
            if (i>0){
                w[i]+=w[i-1];
            }
        }
        int min=Integer.MAX_VALUE;
        for (int i=1;i<n;i++){
            if (Math.abs(w[i-1]-(w[n-1]-w[i-1]))<min){
                min=Math.abs(w[i-1]-(w[n-1]-w[i-1]));
            }
        }
        System.out.println(min);
    }


} Main
import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.List;

public class Main {
    public static void main(String args[]) throws IOException {
        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();
            if (i>0){
                w[i]+=w[i-1];
            }
        }
        int min=Integer.MAX_VALUE;
        for (int i=1;i<n;i++){
            if (Math.abs(w[i-1]-(w[n-1]-w[i-1]))<min){
                min=Math.abs(w[i-1]-(w[n-1]-w[i-1]));
            }
        }
        System.out.println(min);
    }


}

