import 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];
        int totalW = 0;
        int S1 = 0;
        int S2 = 0;
        int minAbs = Integer.MAX_VALUE;

        for (int i = 0; i < N; i++) {
            W[i] = sc.nextInt();
            totalW = totalW + W[i];
        }

        for (int i = 0; i < N; i++) {
            S1 = S1 + W[i];
            S2 = totalW - S1;
            if (Math.abs(S1 - S2) < minAbs) {
                minAbs = Math.abs(S1 - S2);
            }
            if (minAbs == 0) {
                break;
            }
        }
        System.out.println(minAbs);
        sc.close();
    }
} import java.util.*; util.* 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 totalW = 0;
        int S1 = 0;
        int S2 = 0;
        int minAbs = Integer.MAX_VALUE;

        for (int i = 0; i < N; i++) {
            W[i] = sc.nextInt();
            totalW = totalW + W[i];
        }

        for (int i = 0; i < N; i++) {
            S1 = S1 + W[i];
            S2 = totalW - S1;
            if (Math.abs(S1 - S2) < minAbs) {
                minAbs = Math.abs(S1 - S2);
            }
            if (minAbs == 0) {
                break;
            }
        }
        System.out.println(minAbs);
        sc.close();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int W[] = new int[N];
        int totalW = 0;
        int S1 = 0;
        int S2 = 0;
        int minAbs = Integer.MAX_VALUE;

        for (int i = 0; i < N; i++) {
            W[i] = sc.nextInt();
            totalW = totalW + W[i];
        }

        for (int i = 0; i < N; i++) {
            S1 = S1 + W[i];
            S2 = totalW - S1;
            if (Math.abs(S1 - S2) < minAbs) {
                minAbs = Math.abs(S1 - S2);
            }
            if (minAbs == 0) {
                break;
            }
        }
        System.out.println(minAbs);
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int W[] = new int[N];
        int totalW = 0;
        int S1 = 0;
        int S2 = 0;
        int minAbs = Integer.MAX_VALUE;

        for (int i = 0; i < N; i++) {
            W[i] = sc.nextInt();
            totalW = totalW + W[i];
        }

        for (int i = 0; i < N; i++) {
            S1 = S1 + W[i];
            S2 = totalW - S1;
            if (Math.abs(S1 - S2) < minAbs) {
                minAbs = Math.abs(S1 - S2);
            }
            if (minAbs == 0) {
                break;
            }
        }
        System.out.println(minAbs);
        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 int totalW = 0; totalW 0 int S1 = 0; S1 0 int S2 = 0; S2 0 int minAbs = Integer.MAX_VALUE; minAbs Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int i = 0; i < N; i++) {
            W[i] = sc.nextInt();
            totalW = totalW + W[i];
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            W[i] = sc.nextInt();
            totalW = totalW + W[i];
        } {
            W[i] = sc.nextInt();
            totalW = totalW + W[i];
        } W[i] = sc.nextInt() W[i] W i sc.nextInt() sc.nextInt sc totalW = totalW + W[i] totalW totalW + W[i] totalW W[i] W i for (int i = 0; i < N; i++) {
            S1 = S1 + W[i];
            S2 = totalW - S1;
            if (Math.abs(S1 - S2) < minAbs) {
                minAbs = Math.abs(S1 - S2);
            }
            if (minAbs == 0) {
                break;
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            S1 = S1 + W[i];
            S2 = totalW - S1;
            if (Math.abs(S1 - S2) < minAbs) {
                minAbs = Math.abs(S1 - S2);
            }
            if (minAbs == 0) {
                break;
            }
        } {
            S1 = S1 + W[i];
            S2 = totalW - S1;
            if (Math.abs(S1 - S2) < minAbs) {
                minAbs = Math.abs(S1 - S2);
            }
            if (minAbs == 0) {
                break;
            }
        } S1 = S1 + W[i] S1 S1 + W[i] S1 W[i] W i S2 = totalW - S1 S2 totalW - S1 totalW S1 if (Math.abs(S1 - S2) < minAbs) {
                minAbs = Math.abs(S1 - S2);
            } Math.abs(S1 - S2) < minAbs Math.abs(S1 - S2) Math.abs Math S1 - S2 S1 S2 minAbs {
                minAbs = Math.abs(S1 - S2);
            } minAbs = Math.abs(S1 - S2) minAbs Math.abs(S1 - S2) Math.abs Math S1 - S2 S1 S2 if (minAbs == 0) {
                break;
            } minAbs == 0 minAbs 0 {
                break;
            } break; System.out.println(minAbs) System.out.println System.out System System.out minAbs 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];
        int totalW = 0;
        int S1 = 0;
        int S2 = 0;
        int minAbs = Integer.MAX_VALUE;

        for (int i = 0; i < N; i++) {
            W[i] = sc.nextInt();
            totalW = totalW + W[i];
        }

        for (int i = 0; i < N; i++) {
            S1 = S1 + W[i];
            S2 = totalW - S1;
            if (Math.abs(S1 - S2) < minAbs) {
                minAbs = Math.abs(S1 - S2);
            }
            if (minAbs == 0) {
                break;
            }
        }
        System.out.println(minAbs);
        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];
        int totalW = 0;
        int S1 = 0;
        int S2 = 0;
        int minAbs = Integer.MAX_VALUE;

        for (int i = 0; i < N; i++) {
            W[i] = sc.nextInt();
            totalW = totalW + W[i];
        }

        for (int i = 0; i < N; i++) {
            S1 = S1 + W[i];
            S2 = totalW - S1;
            if (Math.abs(S1 - S2) < minAbs) {
                minAbs = Math.abs(S1 - S2);
            }
            if (minAbs == 0) {
                break;
            }
        }
        System.out.println(minAbs);
        sc.close();
    }
} Main
import 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];
        int totalW = 0;
        int S1 = 0;
        int S2 = 0;
        int minAbs = Integer.MAX_VALUE;

        for (int i = 0; i < N; i++) {
            W[i] = sc.nextInt();
            totalW = totalW + W[i];
        }

        for (int i = 0; i < N; i++) {
            S1 = S1 + W[i];
            S2 = totalW - S1;
            if (Math.abs(S1 - S2) < minAbs) {
                minAbs = Math.abs(S1 - S2);
            }
            if (minAbs == 0) {
                break;
            }
        }
        System.out.println(minAbs);
        sc.close();
    }
}