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+1];
        w[0]=0;
        for (int i=0;i<n;i++)w[i+1]=w[i]+sc.nextInt();
        int ans = Integer.MAX_VALUE;
        for (int i=1;i<n;i++)ans=Math.min(ans,Math.abs(w[n]-2*w[i]));
        System.out.println(ans);
    }
} 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+1];
        w[0]=0;
        for (int i=0;i<n;i++)w[i+1]=w[i]+sc.nextInt();
        int ans = Integer.MAX_VALUE;
        for (int i=1;i<n;i++)ans=Math.min(ans,Math.abs(w[n]-2*w[i]));
        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] w = new int[n+1];
        w[0]=0;
        for (int i=0;i<n;i++)w[i+1]=w[i]+sc.nextInt();
        int ans = Integer.MAX_VALUE;
        for (int i=1;i<n;i++)ans=Math.min(ans,Math.abs(w[n]-2*w[i]));
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] w = new int[n+1];
        w[0]=0;
        for (int i=0;i<n;i++)w[i+1]=w[i]+sc.nextInt();
        int ans = Integer.MAX_VALUE;
        for (int i=1;i<n;i++)ans=Math.min(ans,Math.abs(w[n]-2*w[i]));
        System.out.println(ans);
    } 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+1]; w new int[n+1] n+1 n 1 w[0]=0 w[0] w 0 0 for (int i=0;i<n;i++)w[i+1]=w[i]+sc.nextInt(); int i=0; int i=0; i 0 i<n i n i++ i++ i w[i+1]=w[i]+sc.nextInt(); w[i+1]=w[i]+sc.nextInt() w[i+1] w i+1 i 1 w[i]+sc.nextInt() w[i] w i sc.nextInt() sc.nextInt sc int ans = Integer.MAX_VALUE; ans Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int i=1;i<n;i++)ans=Math.min(ans,Math.abs(w[n]-2*w[i])); int i=1; int i=1; i 1 i<n i n i++ i++ i ans=Math.min(ans,Math.abs(w[n]-2*w[i])); ans=Math.min(ans,Math.abs(w[n]-2*w[i])) ans Math.min(ans,Math.abs(w[n]-2*w[i])) Math.min Math ans Math.abs(w[n]-2*w[i]) Math.abs Math w[n]-2*w[i] w[n] w n 2*w[i] 2 w[i] w i System.out.println(ans) System.out.println System.out System System.out ans 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+1];
        w[0]=0;
        for (int i=0;i<n;i++)w[i+1]=w[i]+sc.nextInt();
        int ans = Integer.MAX_VALUE;
        for (int i=1;i<n;i++)ans=Math.min(ans,Math.abs(w[n]-2*w[i]));
        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] w = new int[n+1];
        w[0]=0;
        for (int i=0;i<n;i++)w[i+1]=w[i]+sc.nextInt();
        int ans = Integer.MAX_VALUE;
        for (int i=1;i<n;i++)ans=Math.min(ans,Math.abs(w[n]-2*w[i]));
        System.out.println(ans);
    }
} 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+1];
        w[0]=0;
        for (int i=0;i<n;i++)w[i+1]=w[i]+sc.nextInt();
        int ans = Integer.MAX_VALUE;
        for (int i=1;i<n;i++)ans=Math.min(ans,Math.abs(w[n]-2*w[i]));
        System.out.println(ans);
    }
}
