import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] W = new int[N];
            for (int i = 0; i < N; i++) {
                W[i] = in.nextInt();
            }

            int min = (int) 1e9;
            for (int T = 0; T < N; T++) {
                int s1 = 0;
                for (int i = 0; i < T; i++) {
                    s1 += W[i];
                }
                int s2 = 0;
                for (int i = T; i < N; i++) {
                    s2 += W[i];
                }
                min = Math.min(min, Math.abs(s1 - s2));
            }

            System.out.println(min);
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] W = new int[N];
            for (int i = 0; i < N; i++) {
                W[i] = in.nextInt();
            }

            int min = (int) 1e9;
            for (int T = 0; T < N; T++) {
                int s1 = 0;
                for (int i = 0; i < T; i++) {
                    s1 += W[i];
                }
                int s2 = 0;
                for (int i = T; i < N; i++) {
                    s2 += W[i];
                }
                min = Math.min(min, Math.abs(s1 - s2));
            }

            System.out.println(min);
        }
    }
} Main public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] W = new int[N];
            for (int i = 0; i < N; i++) {
                W[i] = in.nextInt();
            }

            int min = (int) 1e9;
            for (int T = 0; T < N; T++) {
                int s1 = 0;
                for (int i = 0; i < T; i++) {
                    s1 += W[i];
                }
                int s2 = 0;
                for (int i = T; i < N; i++) {
                    s2 += W[i];
                }
                min = Math.min(min, Math.abs(s1 - s2));
            }

            System.out.println(min);
        }
    } main {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] W = new int[N];
            for (int i = 0; i < N; i++) {
                W[i] = in.nextInt();
            }

            int min = (int) 1e9;
            for (int T = 0; T < N; T++) {
                int s1 = 0;
                for (int i = 0; i < T; i++) {
                    s1 += W[i];
                }
                int s2 = 0;
                for (int i = T; i < N; i++) {
                    s2 += W[i];
                }
                min = Math.min(min, Math.abs(s1 - s2));
            }

            System.out.println(min);
        }
    } try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] W = new int[N];
            for (int i = 0; i < N; i++) {
                W[i] = in.nextInt();
            }

            int min = (int) 1e9;
            for (int T = 0; T < N; T++) {
                int s1 = 0;
                for (int i = 0; i < T; i++) {
                    s1 += W[i];
                }
                int s2 = 0;
                for (int i = T; i < N; i++) {
                    s2 += W[i];
                }
                min = Math.min(min, Math.abs(s1 - s2));
            }

            System.out.println(min);
        } {
            int N = in.nextInt();
            int[] W = new int[N];
            for (int i = 0; i < N; i++) {
                W[i] = in.nextInt();
            }

            int min = (int) 1e9;
            for (int T = 0; T < N; T++) {
                int s1 = 0;
                for (int i = 0; i < T; i++) {
                    s1 += W[i];
                }
                int s2 = 0;
                for (int i = T; i < N; i++) {
                    s2 += W[i];
                }
                min = Math.min(min, Math.abs(s1 - s2));
            }

            System.out.println(min);
        } Scanner in = new Scanner(System.in) Scanner in = new Scanner(System.in) new Scanner(System.in) int N = in.nextInt(); N in.nextInt() in.nextInt in int[] W = new int[N]; W new int[N] N for (int i = 0; i < N; i++) {
                W[i] = in.nextInt();
            } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
                W[i] = in.nextInt();
            } {
                W[i] = in.nextInt();
            } W[i] = in.nextInt() W[i] W i in.nextInt() in.nextInt in int min = (int) 1e9; min (int) 1e9 for (int T = 0; T < N; T++) {
                int s1 = 0;
                for (int i = 0; i < T; i++) {
                    s1 += W[i];
                }
                int s2 = 0;
                for (int i = T; i < N; i++) {
                    s2 += W[i];
                }
                min = Math.min(min, Math.abs(s1 - s2));
            } int T = 0; int T = 0; T 0 T < N T N T++ T++ T {
                int s1 = 0;
                for (int i = 0; i < T; i++) {
                    s1 += W[i];
                }
                int s2 = 0;
                for (int i = T; i < N; i++) {
                    s2 += W[i];
                }
                min = Math.min(min, Math.abs(s1 - s2));
            } {
                int s1 = 0;
                for (int i = 0; i < T; i++) {
                    s1 += W[i];
                }
                int s2 = 0;
                for (int i = T; i < N; i++) {
                    s2 += W[i];
                }
                min = Math.min(min, Math.abs(s1 - s2));
            } int s1 = 0; s1 0 for (int i = 0; i < T; i++) {
                    s1 += W[i];
                } int i = 0; int i = 0; i 0 i < T i T i++ i++ i {
                    s1 += W[i];
                } {
                    s1 += W[i];
                } s1 += W[i] s1 W[i] W i int s2 = 0; s2 0 for (int i = T; i < N; i++) {
                    s2 += W[i];
                } int i = T; int i = T; i T i < N i N i++ i++ i {
                    s2 += W[i];
                } {
                    s2 += W[i];
                } s2 += W[i] s2 W[i] W i min = Math.min(min, Math.abs(s1 - s2)) min Math.min(min, Math.abs(s1 - s2)) Math.min Math min Math.abs(s1 - s2) Math.abs Math s1 - s2 s1 s2 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) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] W = new int[N];
            for (int i = 0; i < N; i++) {
                W[i] = in.nextInt();
            }

            int min = (int) 1e9;
            for (int T = 0; T < N; T++) {
                int s1 = 0;
                for (int i = 0; i < T; i++) {
                    s1 += W[i];
                }
                int s2 = 0;
                for (int i = T; i < N; i++) {
                    s2 += W[i];
                }
                min = Math.min(min, Math.abs(s1 - s2));
            }

            System.out.println(min);
        }
    }
} public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] W = new int[N];
            for (int i = 0; i < N; i++) {
                W[i] = in.nextInt();
            }

            int min = (int) 1e9;
            for (int T = 0; T < N; T++) {
                int s1 = 0;
                for (int i = 0; i < T; i++) {
                    s1 += W[i];
                }
                int s2 = 0;
                for (int i = T; i < N; i++) {
                    s2 += W[i];
                }
                min = Math.min(min, Math.abs(s1 - s2));
            }

            System.out.println(min);
        }
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] W = new int[N];
            for (int i = 0; i < N; i++) {
                W[i] = in.nextInt();
            }

            int min = (int) 1e9;
            for (int T = 0; T < N; T++) {
                int s1 = 0;
                for (int i = 0; i < T; i++) {
                    s1 += W[i];
                }
                int s2 = 0;
                for (int i = T; i < N; i++) {
                    s2 += W[i];
                }
                min = Math.min(min, Math.abs(s1 - s2));
            }

            System.out.println(min);
        }
    }
}
