import 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+1];
        for(int i = 1;i<=n;i++){
            w[i] += w[i-1] + Integer.parseInt(sc.next());
        }
        int min = Integer.MAX_VALUE;
        for(int i = 1;i<=n;i++){
            if(min > Math.abs(w[n] - w[i] * 2)){
                min = Math.abs(w[n] - w[i] * 2);
            }
        }
        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 = Integer.parseInt(sc.next());
        int[] w = new int[n+1];
        for(int i = 1;i<=n;i++){
            w[i] += w[i-1] + Integer.parseInt(sc.next());
        }
        int min = Integer.MAX_VALUE;
        for(int i = 1;i<=n;i++){
            if(min > Math.abs(w[n] - w[i] * 2)){
                min = Math.abs(w[n] - w[i] * 2);
            }
        }
        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+1];
        for(int i = 1;i<=n;i++){
            w[i] += w[i-1] + Integer.parseInt(sc.next());
        }
        int min = Integer.MAX_VALUE;
        for(int i = 1;i<=n;i++){
            if(min > Math.abs(w[n] - w[i] * 2)){
                min = Math.abs(w[n] - w[i] * 2);
            }
        }
        System.out.println(min);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] w = new int[n+1];
        for(int i = 1;i<=n;i++){
            w[i] += w[i-1] + Integer.parseInt(sc.next());
        }
        int min = Integer.MAX_VALUE;
        for(int i = 1;i<=n;i++){
            if(min > Math.abs(w[n] - w[i] * 2)){
                min = Math.abs(w[n] - w[i] * 2);
            }
        }
        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+1]; w new int[n+1] n+1 n 1 for(int i = 1;i<=n;i++){
            w[i] += w[i-1] + Integer.parseInt(sc.next());
        } int i = 1; int i = 1; i 1 i<=n i n i++ i++ i {
            w[i] += w[i-1] + Integer.parseInt(sc.next());
        } {
            w[i] += w[i-1] + Integer.parseInt(sc.next());
        } w[i] += w[i-1] + Integer.parseInt(sc.next()) w[i] w i w[i-1] + Integer.parseInt(sc.next()) w[i-1] w i-1 i 1 Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int min = Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE for(int i = 1;i<=n;i++){
            if(min > Math.abs(w[n] - w[i] * 2)){
                min = Math.abs(w[n] - w[i] * 2);
            }
        } int i = 1; int i = 1; i 1 i<=n i n i++ i++ i {
            if(min > Math.abs(w[n] - w[i] * 2)){
                min = Math.abs(w[n] - w[i] * 2);
            }
        } {
            if(min > Math.abs(w[n] - w[i] * 2)){
                min = Math.abs(w[n] - w[i] * 2);
            }
        } if(min > Math.abs(w[n] - w[i] * 2)){
                min = Math.abs(w[n] - w[i] * 2);
            } min > Math.abs(w[n] - w[i] * 2) min Math.abs(w[n] - w[i] * 2) Math.abs Math w[n] - w[i] * 2 w[n] w n w[i] * 2 w[i] w i 2 {
                min = Math.abs(w[n] - w[i] * 2);
            } min = Math.abs(w[n] - w[i] * 2) min Math.abs(w[n] - w[i] * 2) Math.abs Math w[n] - w[i] * 2 w[n] w n w[i] * 2 w[i] w i 2 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+1];
        for(int i = 1;i<=n;i++){
            w[i] += w[i-1] + Integer.parseInt(sc.next());
        }
        int min = Integer.MAX_VALUE;
        for(int i = 1;i<=n;i++){
            if(min > Math.abs(w[n] - w[i] * 2)){
                min = Math.abs(w[n] - w[i] * 2);
            }
        }
        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+1];
        for(int i = 1;i<=n;i++){
            w[i] += w[i-1] + Integer.parseInt(sc.next());
        }
        int min = Integer.MAX_VALUE;
        for(int i = 1;i<=n;i++){
            if(min > Math.abs(w[n] - w[i] * 2)){
                min = Math.abs(w[n] - w[i] * 2);
            }
        }
        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 = Integer.parseInt(sc.next());
        int[] w = new int[n+1];
        for(int i = 1;i<=n;i++){
            w[i] += w[i-1] + Integer.parseInt(sc.next());
        }
        int min = Integer.MAX_VALUE;
        for(int i = 1;i<=n;i++){
            if(min > Math.abs(w[n] - w[i] * 2)){
                min = Math.abs(w[n] - w[i] * 2);
            }
        }
        System.out.println(min);
    }
}