import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        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 l = 0, r = n - 1;
        int s1 = 0, s2 = 0;
        while (l <= r) {
            if (s1 <= s2) {
                s1 += w[l++];
            } else {
                s2 += w[r--];
            }
        }

        System.out.println(Math.abs(s1 - s2));
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        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 l = 0, r = n - 1;
        int s1 = 0, s2 = 0;
        while (l <= r) {
            if (s1 <= s2) {
                s1 += w[l++];
            } else {
                s2 += w[r--];
            }
        }

        System.out.println(Math.abs(s1 - s2));
    }
} Main public static void main(String[] args) {
        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 l = 0, r = n - 1;
        int s1 = 0, s2 = 0;
        while (l <= r) {
            if (s1 <= s2) {
                s1 += w[l++];
            } else {
                s2 += w[r--];
            }
        }

        System.out.println(Math.abs(s1 - s2));
    } main {
        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 l = 0, r = n - 1;
        int s1 = 0, s2 = 0;
        while (l <= r) {
            if (s1 <= s2) {
                s1 += w[l++];
            } else {
                s2 += w[r--];
            }
        }

        System.out.println(Math.abs(s1 - s2));
    } Scanner in = new Scanner(System.in); 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 l = 0 l 0 r = n - 1; r n - 1 n 1 int s1 = 0 s1 0 s2 = 0; s2 0 while (l <= r) {
            if (s1 <= s2) {
                s1 += w[l++];
            } else {
                s2 += w[r--];
            }
        } l <= r l r {
            if (s1 <= s2) {
                s1 += w[l++];
            } else {
                s2 += w[r--];
            }
        } if (s1 <= s2) {
                s1 += w[l++];
            } else {
                s2 += w[r--];
            } s1 <= s2 s1 s2 {
                s1 += w[l++];
            } s1 += w[l++] s1 w[l++] w l++ l {
                s2 += w[r--];
            } s2 += w[r--] s2 w[r--] w r-- r System.out.println(Math.abs(s1 - s2)) System.out.println System.out System System.out Math.abs(s1 - s2) Math.abs Math s1 - s2 s1 s2 String[] args args public class Main {
    public static void main(String[] args) {
        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 l = 0, r = n - 1;
        int s1 = 0, s2 = 0;
        while (l <= r) {
            if (s1 <= s2) {
                s1 += w[l++];
            } else {
                s2 += w[r--];
            }
        }

        System.out.println(Math.abs(s1 - s2));
    }
} public class Main {
    public static void main(String[] args) {
        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 l = 0, r = n - 1;
        int s1 = 0, s2 = 0;
        while (l <= r) {
            if (s1 <= s2) {
                s1 += w[l++];
            } else {
                s2 += w[r--];
            }
        }

        System.out.println(Math.abs(s1 - s2));
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        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 l = 0, r = n - 1;
        int s1 = 0, s2 = 0;
        while (l <= r) {
            if (s1 <= s2) {
                s1 += w[l++];
            } else {
                s2 += w[r--];
            }
        }

        System.out.println(Math.abs(s1 - s2));
    }
}
