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