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 ans = Integer.MAX_VALUE;
        for (int i = 1; i < w.length; i++) {
            int total1 = 0;
            for (int j = 0; j < i; j++) {
                total1 += w[j];
            }
            int total2 = 0;
            for (int j = i; j < w.length; j++) {
                total2 += w[j];
            }
            int tmp = Math.abs(total2 - total1);
            if(ans > tmp)ans = tmp;
        }
        System.out.println(ans);
    }
} 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 ans = Integer.MAX_VALUE;
        for (int i = 1; i < w.length; i++) {
            int total1 = 0;
            for (int j = 0; j < i; j++) {
                total1 += w[j];
            }
            int total2 = 0;
            for (int j = i; j < w.length; j++) {
                total2 += w[j];
            }
            int tmp = Math.abs(total2 - total1);
            if(ans > tmp)ans = tmp;
        }
        System.out.println(ans);
    }
} 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 ans = Integer.MAX_VALUE;
        for (int i = 1; i < w.length; i++) {
            int total1 = 0;
            for (int j = 0; j < i; j++) {
                total1 += w[j];
            }
            int total2 = 0;
            for (int j = i; j < w.length; j++) {
                total2 += w[j];
            }
            int tmp = Math.abs(total2 - total1);
            if(ans > tmp)ans = tmp;
        }
        System.out.println(ans);
    } 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 ans = Integer.MAX_VALUE;
        for (int i = 1; i < w.length; i++) {
            int total1 = 0;
            for (int j = 0; j < i; j++) {
                total1 += w[j];
            }
            int total2 = 0;
            for (int j = i; j < w.length; j++) {
                total2 += w[j];
            }
            int tmp = Math.abs(total2 - total1);
            if(ans > tmp)ans = tmp;
        }
        System.out.println(ans);
    } 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 ans = Integer.MAX_VALUE; ans Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int i = 1; i < w.length; i++) {
            int total1 = 0;
            for (int j = 0; j < i; j++) {
                total1 += w[j];
            }
            int total2 = 0;
            for (int j = i; j < w.length; j++) {
                total2 += w[j];
            }
            int tmp = Math.abs(total2 - total1);
            if(ans > tmp)ans = tmp;
        } int i = 1; int i = 1; i 1 i < w.length i w.length w w.length i++ i++ i {
            int total1 = 0;
            for (int j = 0; j < i; j++) {
                total1 += w[j];
            }
            int total2 = 0;
            for (int j = i; j < w.length; j++) {
                total2 += w[j];
            }
            int tmp = Math.abs(total2 - total1);
            if(ans > tmp)ans = tmp;
        } {
            int total1 = 0;
            for (int j = 0; j < i; j++) {
                total1 += w[j];
            }
            int total2 = 0;
            for (int j = i; j < w.length; j++) {
                total2 += w[j];
            }
            int tmp = Math.abs(total2 - total1);
            if(ans > tmp)ans = tmp;
        } int total1 = 0; total1 0 for (int j = 0; j < i; j++) {
                total1 += w[j];
            } int j = 0; int j = 0; j 0 j < i j i j++ j++ j {
                total1 += w[j];
            } {
                total1 += w[j];
            } total1 += w[j] total1 w[j] w j int total2 = 0; total2 0 for (int j = i; j < w.length; j++) {
                total2 += w[j];
            } int j = i; int j = i; j i j < w.length j w.length w w.length j++ j++ j {
                total2 += w[j];
            } {
                total2 += w[j];
            } total2 += w[j] total2 w[j] w j int tmp = Math.abs(total2 - total1); tmp Math.abs(total2 - total1) Math.abs Math total2 - total1 total2 total1 if(ans > tmp)ans = tmp; ans > tmp ans tmp ans = tmp ans tmp System.out.println(ans) System.out.println System.out System System.out ans 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 ans = Integer.MAX_VALUE;
        for (int i = 1; i < w.length; i++) {
            int total1 = 0;
            for (int j = 0; j < i; j++) {
                total1 += w[j];
            }
            int total2 = 0;
            for (int j = i; j < w.length; j++) {
                total2 += w[j];
            }
            int tmp = Math.abs(total2 - total1);
            if(ans > tmp)ans = tmp;
        }
        System.out.println(ans);
    }
} 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 ans = Integer.MAX_VALUE;
        for (int i = 1; i < w.length; i++) {
            int total1 = 0;
            for (int j = 0; j < i; j++) {
                total1 += w[j];
            }
            int total2 = 0;
            for (int j = i; j < w.length; j++) {
                total2 += w[j];
            }
            int tmp = Math.abs(total2 - total1);
            if(ans > tmp)ans = tmp;
        }
        System.out.println(ans);
    }
} 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 ans = Integer.MAX_VALUE;
        for (int i = 1; i < w.length; i++) {
            int total1 = 0;
            for (int j = 0; j < i; j++) {
                total1 += w[j];
            }
            int total2 = 0;
            for (int j = i; j < w.length; j++) {
                total2 += w[j];
            }
            int tmp = Math.abs(total2 - total1);
            if(ans > tmp)ans = tmp;
        }
        System.out.println(ans);
    }
}