//ｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｹｯｺｯｯｺｰｰｰｰ!!!!!!wwwwwwwwwww
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];
        int a = 0;
        int b = 0;
        for(int i = 0 ; i < n ; i++){
            w[i] = sc.nextInt();
            b += w[i];
        }
        a += w[0];
        b -= w[0];
        int yono = 1000000;
        for(int i = 1 ; i < n ; i++){
            yono = Math.min(yono , Math.abs(a - b));
            a += w[i];
            b -= w[i];
        }
        System.out.println(yono);
    }
} 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];
        int a = 0;
        int b = 0;
        for(int i = 0 ; i < n ; i++){
            w[i] = sc.nextInt();
            b += w[i];
        }
        a += w[0];
        b -= w[0];
        int yono = 1000000;
        for(int i = 1 ; i < n ; i++){
            yono = Math.min(yono , Math.abs(a - b));
            a += w[i];
            b -= w[i];
        }
        System.out.println(yono);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] w = new int[n];
        int a = 0;
        int b = 0;
        for(int i = 0 ; i < n ; i++){
            w[i] = sc.nextInt();
            b += w[i];
        }
        a += w[0];
        b -= w[0];
        int yono = 1000000;
        for(int i = 1 ; i < n ; i++){
            yono = Math.min(yono , Math.abs(a - b));
            a += w[i];
            b -= w[i];
        }
        System.out.println(yono);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] w = new int[n];
        int a = 0;
        int b = 0;
        for(int i = 0 ; i < n ; i++){
            w[i] = sc.nextInt();
            b += w[i];
        }
        a += w[0];
        b -= w[0];
        int yono = 1000000;
        for(int i = 1 ; i < n ; i++){
            yono = Math.min(yono , Math.abs(a - b));
            a += w[i];
            b -= w[i];
        }
        System.out.println(yono);
    } 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 int a = 0; a 0 int b = 0; b 0 for(int i = 0 ; i < n ; i++){
            w[i] = sc.nextInt();
            b += w[i];
        } int i = 0 ; int i = 0 ; i 0 i < n i n i++ i++ i {
            w[i] = sc.nextInt();
            b += w[i];
        } {
            w[i] = sc.nextInt();
            b += w[i];
        } w[i] = sc.nextInt() w[i] w i sc.nextInt() sc.nextInt sc b += w[i] b w[i] w i a += w[0] a w[0] w 0 b -= w[0] b w[0] w 0 int yono = 1000000; yono 1000000 for(int i = 1 ; i < n ; i++){
            yono = Math.min(yono , Math.abs(a - b));
            a += w[i];
            b -= w[i];
        } int i = 1 ; int i = 1 ; i 1 i < n i n i++ i++ i {
            yono = Math.min(yono , Math.abs(a - b));
            a += w[i];
            b -= w[i];
        } {
            yono = Math.min(yono , Math.abs(a - b));
            a += w[i];
            b -= w[i];
        } yono = Math.min(yono , Math.abs(a - b)) yono Math.min(yono , Math.abs(a - b)) Math.min Math yono Math.abs(a - b) Math.abs Math a - b a b a += w[i] a w[i] w i b -= w[i] b w[i] w i System.out.println(yono) System.out.println System.out System System.out yono 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];
        int a = 0;
        int b = 0;
        for(int i = 0 ; i < n ; i++){
            w[i] = sc.nextInt();
            b += w[i];
        }
        a += w[0];
        b -= w[0];
        int yono = 1000000;
        for(int i = 1 ; i < n ; i++){
            yono = Math.min(yono , Math.abs(a - b));
            a += w[i];
            b -= w[i];
        }
        System.out.println(yono);
    }
} public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] w = new int[n];
        int a = 0;
        int b = 0;
        for(int i = 0 ; i < n ; i++){
            w[i] = sc.nextInt();
            b += w[i];
        }
        a += w[0];
        b -= w[0];
        int yono = 1000000;
        for(int i = 1 ; i < n ; i++){
            yono = Math.min(yono , Math.abs(a - b));
            a += w[i];
            b -= w[i];
        }
        System.out.println(yono);
    }
} Main
//ｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｹｯｺｯｯｺｰｰｰｰ!!!!!!wwwwwwwwwww
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];
        int a = 0;
        int b = 0;
        for(int i = 0 ; i < n ; i++){
            w[i] = sc.nextInt();
            b += w[i];
        }
        a += w[0];
        b -= w[0];
        int yono = 1000000;
        for(int i = 1 ; i < n ; i++){
            yono = Math.min(yono , Math.abs(a - b));
            a += w[i];
            b -= w[i];
        }
        System.out.println(yono);
    }
}