import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] w = new int[n];
        for (int i = 0; i < w.length; i++) {
            w[i] = sc.nextInt();
        }
        int result = 0;
        for (int i = 0; i < w.length - 1; i++) {
            int s1 = 0, s2 = 0;
            for (int j = 0; j < w.length; j++) {
                if (j <= i) {
                    s1 += w[j];
                } else {
                    s2 += w[j];
                }
            }
            if (i == 0) {
                result = Math.abs(s1 - s2);
            } else {
                result = Math.min(result, Math.abs(s1 - s2));
            }
        }
        System.out.println(result); 
        sc.close();
    }
} import java.util.Scanner; Scanner 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];
        for (int i = 0; i < w.length; i++) {
            w[i] = sc.nextInt();
        }
        int result = 0;
        for (int i = 0; i < w.length - 1; i++) {
            int s1 = 0, s2 = 0;
            for (int j = 0; j < w.length; j++) {
                if (j <= i) {
                    s1 += w[j];
                } else {
                    s2 += w[j];
                }
            }
            if (i == 0) {
                result = Math.abs(s1 - s2);
            } else {
                result = Math.min(result, Math.abs(s1 - s2));
            }
        }
        System.out.println(result); 
        sc.close();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] w = new int[n];
        for (int i = 0; i < w.length; i++) {
            w[i] = sc.nextInt();
        }
        int result = 0;
        for (int i = 0; i < w.length - 1; i++) {
            int s1 = 0, s2 = 0;
            for (int j = 0; j < w.length; j++) {
                if (j <= i) {
                    s1 += w[j];
                } else {
                    s2 += w[j];
                }
            }
            if (i == 0) {
                result = Math.abs(s1 - s2);
            } else {
                result = Math.min(result, Math.abs(s1 - s2));
            }
        }
        System.out.println(result); 
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] w = new int[n];
        for (int i = 0; i < w.length; i++) {
            w[i] = sc.nextInt();
        }
        int result = 0;
        for (int i = 0; i < w.length - 1; i++) {
            int s1 = 0, s2 = 0;
            for (int j = 0; j < w.length; j++) {
                if (j <= i) {
                    s1 += w[j];
                } else {
                    s2 += w[j];
                }
            }
            if (i == 0) {
                result = Math.abs(s1 - s2);
            } else {
                result = Math.min(result, Math.abs(s1 - s2));
            }
        }
        System.out.println(result); 
        sc.close();
    } 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 < w.length; i++) {
            w[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < w.length i w.length w w.length i++ i++ i {
            w[i] = sc.nextInt();
        } {
            w[i] = sc.nextInt();
        } w[i] = sc.nextInt() w[i] w i sc.nextInt() sc.nextInt sc int result = 0; result 0 for (int i = 0; i < w.length - 1; i++) {
            int s1 = 0, s2 = 0;
            for (int j = 0; j < w.length; j++) {
                if (j <= i) {
                    s1 += w[j];
                } else {
                    s2 += w[j];
                }
            }
            if (i == 0) {
                result = Math.abs(s1 - s2);
            } else {
                result = Math.min(result, Math.abs(s1 - s2));
            }
        } int i = 0; int i = 0; i 0 i < w.length - 1 i w.length - 1 w.length w w.length 1 i++ i++ i {
            int s1 = 0, s2 = 0;
            for (int j = 0; j < w.length; j++) {
                if (j <= i) {
                    s1 += w[j];
                } else {
                    s2 += w[j];
                }
            }
            if (i == 0) {
                result = Math.abs(s1 - s2);
            } else {
                result = Math.min(result, Math.abs(s1 - s2));
            }
        } {
            int s1 = 0, s2 = 0;
            for (int j = 0; j < w.length; j++) {
                if (j <= i) {
                    s1 += w[j];
                } else {
                    s2 += w[j];
                }
            }
            if (i == 0) {
                result = Math.abs(s1 - s2);
            } else {
                result = Math.min(result, Math.abs(s1 - s2));
            }
        } int s1 = 0 s1 0 s2 = 0; s2 0 for (int j = 0; j < w.length; j++) {
                if (j <= i) {
                    s1 += w[j];
                } else {
                    s2 += w[j];
                }
            } int j = 0; int j = 0; j 0 j < w.length j w.length w w.length j++ j++ j {
                if (j <= i) {
                    s1 += w[j];
                } else {
                    s2 += w[j];
                }
            } {
                if (j <= i) {
                    s1 += w[j];
                } else {
                    s2 += w[j];
                }
            } if (j <= i) {
                    s1 += w[j];
                } else {
                    s2 += w[j];
                } j <= i j i {
                    s1 += w[j];
                } s1 += w[j] s1 w[j] w j {
                    s2 += w[j];
                } s2 += w[j] s2 w[j] w j if (i == 0) {
                result = Math.abs(s1 - s2);
            } else {
                result = Math.min(result, Math.abs(s1 - s2));
            } i == 0 i 0 {
                result = Math.abs(s1 - s2);
            } result = Math.abs(s1 - s2) result Math.abs(s1 - s2) Math.abs Math s1 - s2 s1 s2 {
                result = Math.min(result, Math.abs(s1 - s2));
            } result = Math.min(result, Math.abs(s1 - s2)) result Math.min(result, Math.abs(s1 - s2)) Math.min Math result Math.abs(s1 - s2) Math.abs Math s1 - s2 s1 s2 System.out.println(result) System.out.println System.out System System.out result sc.close() sc.close sc 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];
        for (int i = 0; i < w.length; i++) {
            w[i] = sc.nextInt();
        }
        int result = 0;
        for (int i = 0; i < w.length - 1; i++) {
            int s1 = 0, s2 = 0;
            for (int j = 0; j < w.length; j++) {
                if (j <= i) {
                    s1 += w[j];
                } else {
                    s2 += w[j];
                }
            }
            if (i == 0) {
                result = Math.abs(s1 - s2);
            } else {
                result = Math.min(result, Math.abs(s1 - s2));
            }
        }
        System.out.println(result); 
        sc.close();
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] w = new int[n];
        for (int i = 0; i < w.length; i++) {
            w[i] = sc.nextInt();
        }
        int result = 0;
        for (int i = 0; i < w.length - 1; i++) {
            int s1 = 0, s2 = 0;
            for (int j = 0; j < w.length; j++) {
                if (j <= i) {
                    s1 += w[j];
                } else {
                    s2 += w[j];
                }
            }
            if (i == 0) {
                result = Math.abs(s1 - s2);
            } else {
                result = Math.min(result, Math.abs(s1 - s2));
            }
        }
        System.out.println(result); 
        sc.close();
    }
} Main
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] w = new int[n];
        for (int i = 0; i < w.length; i++) {
            w[i] = sc.nextInt();
        }
        int result = 0;
        for (int i = 0; i < w.length - 1; i++) {
            int s1 = 0, s2 = 0;
            for (int j = 0; j < w.length; j++) {
                if (j <= i) {
                    s1 += w[j];
                } else {
                    s2 += w[j];
                }
            }
            if (i == 0) {
                result = Math.abs(s1 - s2);
            } else {
                result = Math.min(result, Math.abs(s1 - s2));
            }
        }
        System.out.println(result); 
        sc.close();
    }
}