import java.util.Scanner;
import java.util.Arrays;

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

        int left = 0;
        int right = 0;
        int dif = 100000;
        for (int i = 0; i < N; i++) {
            left = sum(Arrays.copyOfRange(W, 0, i));
            right = sum(Arrays.copyOfRange(W, i, W.length));
            dif = Math.min(dif, Math.abs(left - right));
        }
        System.out.println(dif);
    }

    private static int sum(int[] temp) {
        int n = temp.length;
        int ret = 0;
        for (int i = 0; i < n; i++) {
            ret += temp[i];
        }
        return ret;
    }
} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] W = new int[N];
        for (int i = 0; i < N; i++) {
            W[i] = Integer.parseInt(sc.next());
        }

        int left = 0;
        int right = 0;
        int dif = 100000;
        for (int i = 0; i < N; i++) {
            left = sum(Arrays.copyOfRange(W, 0, i));
            right = sum(Arrays.copyOfRange(W, i, W.length));
            dif = Math.min(dif, Math.abs(left - right));
        }
        System.out.println(dif);
    }

    private static int sum(int[] temp) {
        int n = temp.length;
        int ret = 0;
        for (int i = 0; i < n; i++) {
            ret += temp[i];
        }
        return ret;
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] W = new int[N];
        for (int i = 0; i < N; i++) {
            W[i] = Integer.parseInt(sc.next());
        }

        int left = 0;
        int right = 0;
        int dif = 100000;
        for (int i = 0; i < N; i++) {
            left = sum(Arrays.copyOfRange(W, 0, i));
            right = sum(Arrays.copyOfRange(W, i, W.length));
            dif = Math.min(dif, Math.abs(left - right));
        }
        System.out.println(dif);
    } main {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] W = new int[N];
        for (int i = 0; i < N; i++) {
            W[i] = Integer.parseInt(sc.next());
        }

        int left = 0;
        int right = 0;
        int dif = 100000;
        for (int i = 0; i < N; i++) {
            left = sum(Arrays.copyOfRange(W, 0, i));
            right = sum(Arrays.copyOfRange(W, i, W.length));
            dif = Math.min(dif, Math.abs(left - right));
        }
        System.out.println(dif);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = Integer.parseInt(sc.next()); N Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int[] W = new int[N]; W new int[N] N for (int i = 0; i < N; i++) {
            W[i] = Integer.parseInt(sc.next());
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            W[i] = Integer.parseInt(sc.next());
        } {
            W[i] = Integer.parseInt(sc.next());
        } W[i] = Integer.parseInt(sc.next()) W[i] W i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int left = 0; left 0 int right = 0; right 0 int dif = 100000; dif 100000 for (int i = 0; i < N; i++) {
            left = sum(Arrays.copyOfRange(W, 0, i));
            right = sum(Arrays.copyOfRange(W, i, W.length));
            dif = Math.min(dif, Math.abs(left - right));
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            left = sum(Arrays.copyOfRange(W, 0, i));
            right = sum(Arrays.copyOfRange(W, i, W.length));
            dif = Math.min(dif, Math.abs(left - right));
        } {
            left = sum(Arrays.copyOfRange(W, 0, i));
            right = sum(Arrays.copyOfRange(W, i, W.length));
            dif = Math.min(dif, Math.abs(left - right));
        } left = sum(Arrays.copyOfRange(W, 0, i)) left sum(Arrays.copyOfRange(W, 0, i)) sum Arrays.copyOfRange(W, 0, i) Arrays.copyOfRange Arrays W 0 i right = sum(Arrays.copyOfRange(W, i, W.length)) right sum(Arrays.copyOfRange(W, i, W.length)) sum Arrays.copyOfRange(W, i, W.length) Arrays.copyOfRange Arrays W i W.length W W.length dif = Math.min(dif, Math.abs(left - right)) dif Math.min(dif, Math.abs(left - right)) Math.min Math dif Math.abs(left - right) Math.abs Math left - right left right System.out.println(dif) System.out.println System.out System System.out dif String[] args args private static int sum(int[] temp) {
        int n = temp.length;
        int ret = 0;
        for (int i = 0; i < n; i++) {
            ret += temp[i];
        }
        return ret;
    } sum {
        int n = temp.length;
        int ret = 0;
        for (int i = 0; i < n; i++) {
            ret += temp[i];
        }
        return ret;
    } int n = temp.length; n temp.length temp temp.length int ret = 0; ret 0 for (int i = 0; i < n; i++) {
            ret += temp[i];
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            ret += temp[i];
        } {
            ret += temp[i];
        } ret += temp[i] ret temp[i] temp i return ret; ret int[] temp temp public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] W = new int[N];
        for (int i = 0; i < N; i++) {
            W[i] = Integer.parseInt(sc.next());
        }

        int left = 0;
        int right = 0;
        int dif = 100000;
        for (int i = 0; i < N; i++) {
            left = sum(Arrays.copyOfRange(W, 0, i));
            right = sum(Arrays.copyOfRange(W, i, W.length));
            dif = Math.min(dif, Math.abs(left - right));
        }
        System.out.println(dif);
    }

    private static int sum(int[] temp) {
        int n = temp.length;
        int ret = 0;
        for (int i = 0; i < n; i++) {
            ret += temp[i];
        }
        return ret;
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] W = new int[N];
        for (int i = 0; i < N; i++) {
            W[i] = Integer.parseInt(sc.next());
        }

        int left = 0;
        int right = 0;
        int dif = 100000;
        for (int i = 0; i < N; i++) {
            left = sum(Arrays.copyOfRange(W, 0, i));
            right = sum(Arrays.copyOfRange(W, i, W.length));
            dif = Math.min(dif, Math.abs(left - right));
        }
        System.out.println(dif);
    }

    private static int sum(int[] temp) {
        int n = temp.length;
        int ret = 0;
        for (int i = 0; i < n; i++) {
            ret += temp[i];
        }
        return ret;
    }
} Main
import java.util.Scanner;
import java.util.Arrays;

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

        int left = 0;
        int right = 0;
        int dif = 100000;
        for (int i = 0; i < N; i++) {
            left = sum(Arrays.copyOfRange(W, 0, i));
            right = sum(Arrays.copyOfRange(W, i, W.length));
            dif = Math.min(dif, Math.abs(left - right));
        }
        System.out.println(dif);
    }

    private static int sum(int[] temp) {
        int n = temp.length;
        int ret = 0;
        for (int i = 0; i < n; i++) {
            ret += temp[i];
        }
        return ret;
    }
}
