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 sums[] = new int[n-1];

        for (int i=0; i<n; i++){
            w[i] = sc.nextInt();
        }


        for (int t=0; t<n-1; t++) {
            int s1 = 0;
            int s2 = 0;
            for (int x = 0; x < t + 1; x++) {
                s1 += w[x];
            }
            for (int y=t+1; y<n; y++) {
                s2 += w[y];
            }

            int ans = Math.abs(s1-s2);
            sums[t] = ans;

        }

        int max = sums[0];
        int min = sums[1];
        for (int z=1; z<sums.length; z++){
            int v = sums[z];
            if (v > max) max=v;
            if (v < min) min=v;
        }

        System.out.println(min);


        }

    }


 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 sums[] = new int[n-1];

        for (int i=0; i<n; i++){
            w[i] = sc.nextInt();
        }


        for (int t=0; t<n-1; t++) {
            int s1 = 0;
            int s2 = 0;
            for (int x = 0; x < t + 1; x++) {
                s1 += w[x];
            }
            for (int y=t+1; y<n; y++) {
                s2 += w[y];
            }

            int ans = Math.abs(s1-s2);
            sums[t] = ans;

        }

        int max = sums[0];
        int min = sums[1];
        for (int z=1; z<sums.length; z++){
            int v = sums[z];
            if (v > max) max=v;
            if (v < min) min=v;
        }

        System.out.println(min);


        }

    } Main public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int w[] = new int[n];

        int sums[] = new int[n-1];

        for (int i=0; i<n; i++){
            w[i] = sc.nextInt();
        }


        for (int t=0; t<n-1; t++) {
            int s1 = 0;
            int s2 = 0;
            for (int x = 0; x < t + 1; x++) {
                s1 += w[x];
            }
            for (int y=t+1; y<n; y++) {
                s2 += w[y];
            }

            int ans = Math.abs(s1-s2);
            sums[t] = ans;

        }

        int max = sums[0];
        int min = sums[1];
        for (int z=1; z<sums.length; z++){
            int v = sums[z];
            if (v > max) max=v;
            if (v < min) min=v;
        }

        System.out.println(min);


        } main {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int w[] = new int[n];

        int sums[] = new int[n-1];

        for (int i=0; i<n; i++){
            w[i] = sc.nextInt();
        }


        for (int t=0; t<n-1; t++) {
            int s1 = 0;
            int s2 = 0;
            for (int x = 0; x < t + 1; x++) {
                s1 += w[x];
            }
            for (int y=t+1; y<n; y++) {
                s2 += w[y];
            }

            int ans = Math.abs(s1-s2);
            sums[t] = ans;

        }

        int max = sums[0];
        int min = sums[1];
        for (int z=1; z<sums.length; z++){
            int v = sums[z];
            if (v > max) max=v;
            if (v < min) min=v;
        }

        System.out.println(min);


        } 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 sums[] = new int[n-1]; sums new int[n-1] n-1 n 1 for (int i=0; i<n; i++){
            w[i] = sc.nextInt();
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            w[i] = sc.nextInt();
        } {
            w[i] = sc.nextInt();
        } w[i] = sc.nextInt() w[i] w i sc.nextInt() sc.nextInt sc for (int t=0; t<n-1; t++) {
            int s1 = 0;
            int s2 = 0;
            for (int x = 0; x < t + 1; x++) {
                s1 += w[x];
            }
            for (int y=t+1; y<n; y++) {
                s2 += w[y];
            }

            int ans = Math.abs(s1-s2);
            sums[t] = ans;

        } int t=0; int t=0; t 0 t<n-1 t n-1 n 1 t++ t++ t {
            int s1 = 0;
            int s2 = 0;
            for (int x = 0; x < t + 1; x++) {
                s1 += w[x];
            }
            for (int y=t+1; y<n; y++) {
                s2 += w[y];
            }

            int ans = Math.abs(s1-s2);
            sums[t] = ans;

        } {
            int s1 = 0;
            int s2 = 0;
            for (int x = 0; x < t + 1; x++) {
                s1 += w[x];
            }
            for (int y=t+1; y<n; y++) {
                s2 += w[y];
            }

            int ans = Math.abs(s1-s2);
            sums[t] = ans;

        } int s1 = 0; s1 0 int s2 = 0; s2 0 for (int x = 0; x < t + 1; x++) {
                s1 += w[x];
            } int x = 0; int x = 0; x 0 x < t + 1 x t + 1 t 1 x++ x++ x {
                s1 += w[x];
            } {
                s1 += w[x];
            } s1 += w[x] s1 w[x] w x for (int y=t+1; y<n; y++) {
                s2 += w[y];
            } int y=t+1; int y=t+1; y t+1 t 1 y<n y n y++ y++ y {
                s2 += w[y];
            } {
                s2 += w[y];
            } s2 += w[y] s2 w[y] w y int ans = Math.abs(s1-s2); ans Math.abs(s1-s2) Math.abs Math s1-s2 s1 s2 sums[t] = ans sums[t] sums t ans int max = sums[0]; max sums[0] sums 0 int min = sums[1]; min sums[1] sums 1 for (int z=1; z<sums.length; z++){
            int v = sums[z];
            if (v > max) max=v;
            if (v < min) min=v;
        } int z=1; int z=1; z 1 z<sums.length z sums.length sums sums.length z++ z++ z {
            int v = sums[z];
            if (v > max) max=v;
            if (v < min) min=v;
        } {
            int v = sums[z];
            if (v > max) max=v;
            if (v < min) min=v;
        } int v = sums[z]; v sums[z] sums z if (v > max) max=v; v > max v max max=v max v if (v < min) min=v; v < min v min min=v min v 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[]) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int w[] = new int[n];

        int sums[] = new int[n-1];

        for (int i=0; i<n; i++){
            w[i] = sc.nextInt();
        }


        for (int t=0; t<n-1; t++) {
            int s1 = 0;
            int s2 = 0;
            for (int x = 0; x < t + 1; x++) {
                s1 += w[x];
            }
            for (int y=t+1; y<n; y++) {
                s2 += w[y];
            }

            int ans = Math.abs(s1-s2);
            sums[t] = ans;

        }

        int max = sums[0];
        int min = sums[1];
        for (int z=1; z<sums.length; z++){
            int v = sums[z];
            if (v > max) max=v;
            if (v < min) min=v;
        }

        System.out.println(min);


        }

    } 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 sums[] = new int[n-1];

        for (int i=0; i<n; i++){
            w[i] = sc.nextInt();
        }


        for (int t=0; t<n-1; t++) {
            int s1 = 0;
            int s2 = 0;
            for (int x = 0; x < t + 1; x++) {
                s1 += w[x];
            }
            for (int y=t+1; y<n; y++) {
                s2 += w[y];
            }

            int ans = Math.abs(s1-s2);
            sums[t] = ans;

        }

        int max = sums[0];
        int min = sums[1];
        for (int z=1; z<sums.length; z++){
            int v = sums[z];
            if (v > max) max=v;
            if (v < min) min=v;
        }

        System.out.println(min);


        }

    } 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 sums[] = new int[n-1];

        for (int i=0; i<n; i++){
            w[i] = sc.nextInt();
        }


        for (int t=0; t<n-1; t++) {
            int s1 = 0;
            int s2 = 0;
            for (int x = 0; x < t + 1; x++) {
                s1 += w[x];
            }
            for (int y=t+1; y<n; y++) {
                s2 += w[y];
            }

            int ans = Math.abs(s1-s2);
            sums[t] = ans;

        }

        int max = sums[0];
        int min = sums[1];
        for (int z=1; z<sums.length; z++){
            int v = sums[z];
            if (v > max) max=v;
            if (v < min) min=v;
        }

        System.out.println(min);


        }

    }



