import java.util.*;
import java.lang.*;

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 sum = 0;
        for (int i = 0; i < n; i++) {
            sum += sc.nextInt();
            w[i] = sum;
        }
        
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            int r = Math.abs(w[i] - (sum - w[i]));
            if (r < min) {
                min = r;
            }
        }
        System.out.println(min);
    }
} import java.util.*; util.* java import java.lang.*; lang.* 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 sum = 0;
        for (int i = 0; i < n; i++) {
            sum += sc.nextInt();
            w[i] = sum;
        }
        
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            int r = Math.abs(w[i] - (sum - w[i]));
            if (r < min) {
                min = 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];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += sc.nextInt();
            w[i] = sum;
        }
        
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            int r = Math.abs(w[i] - (sum - w[i]));
            if (r < min) {
                min = r;
            }
        }
        System.out.println(min);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] w = new int[n];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += sc.nextInt();
            w[i] = sum;
        }
        
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            int r = Math.abs(w[i] - (sum - w[i]));
            if (r < min) {
                min = 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 int sum = 0; sum 0 for (int i = 0; i < n; i++) {
            sum += sc.nextInt();
            w[i] = sum;
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            sum += sc.nextInt();
            w[i] = sum;
        } {
            sum += sc.nextInt();
            w[i] = sum;
        } sum += sc.nextInt() sum sc.nextInt() sc.nextInt sc w[i] = sum w[i] w i sum int min = Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int i = 0; i < n; i++) {
            int r = Math.abs(w[i] - (sum - w[i]));
            if (r < min) {
                min = r;
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            int r = Math.abs(w[i] - (sum - w[i]));
            if (r < min) {
                min = r;
            }
        } {
            int r = Math.abs(w[i] - (sum - w[i]));
            if (r < min) {
                min = r;
            }
        } int r = Math.abs(w[i] - (sum - w[i])); r Math.abs(w[i] - (sum - w[i])) Math.abs Math w[i] - (sum - w[i]) w[i] w i (sum - w[i]) sum w[i] w i if (r < min) {
                min = r;
            } r < min r min {
                min = r;
            } min = r min 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];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += sc.nextInt();
            w[i] = sum;
        }
        
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            int r = Math.abs(w[i] - (sum - w[i]));
            if (r < min) {
                min = 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];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += sc.nextInt();
            w[i] = sum;
        }
        
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            int r = Math.abs(w[i] - (sum - w[i]));
            if (r < min) {
                min = r;
            }
        }
        System.out.println(min);
    }
} Main
import java.util.*;
import java.lang.*;

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 sum = 0;
        for (int i = 0; i < n; i++) {
            sum += sc.nextInt();
            w[i] = sum;
        }
        
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            int r = Math.abs(w[i] - (sum - w[i]));
            if (r < min) {
                min = r;
            }
        }
        System.out.println(min);
    }
}
