import java.util.*;
import java.io.*;

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int sum=0;
		int [] w=new int [n];
		for(int i=0;i<n;i++)
		{
			w[i]=in.nextInt();
			sum=sum+w[i];
		}
		int min=10000000;
		int leftsum=0;
		for(int i=n-1;i>=0;i--)
		{
			sum=sum-w[i];
			leftsum=leftsum+w[i];
			int diff=Math.abs(sum-leftsum);
			if(min>diff)
				min=diff;
		}
		System.out.println(min);
	}
}
	 import java.util.*; util.* java import java.io.*; io.* java public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int sum=0;
		int [] w=new int [n];
		for(int i=0;i<n;i++)
		{
			w[i]=in.nextInt();
			sum=sum+w[i];
		}
		int min=10000000;
		int leftsum=0;
		for(int i=n-1;i>=0;i--)
		{
			sum=sum-w[i];
			leftsum=leftsum+w[i];
			int diff=Math.abs(sum-leftsum);
			if(min>diff)
				min=diff;
		}
		System.out.println(min);
	}
} Main public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int sum=0;
		int [] w=new int [n];
		for(int i=0;i<n;i++)
		{
			w[i]=in.nextInt();
			sum=sum+w[i];
		}
		int min=10000000;
		int leftsum=0;
		for(int i=n-1;i>=0;i--)
		{
			sum=sum-w[i];
			leftsum=leftsum+w[i];
			int diff=Math.abs(sum-leftsum);
			if(min>diff)
				min=diff;
		}
		System.out.println(min);
	} main {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int sum=0;
		int [] w=new int [n];
		for(int i=0;i<n;i++)
		{
			w[i]=in.nextInt();
			sum=sum+w[i];
		}
		int min=10000000;
		int leftsum=0;
		for(int i=n-1;i>=0;i--)
		{
			sum=sum-w[i];
			leftsum=leftsum+w[i];
			int diff=Math.abs(sum-leftsum);
			if(min>diff)
				min=diff;
		}
		System.out.println(min);
	} Scanner in=new Scanner(System.in); in new Scanner(System.in) int n=in.nextInt(); n in.nextInt() in.nextInt in int sum=0; sum 0 int [] w=new int [n]; w new int [n] n for(int i=0;i<n;i++)
		{
			w[i]=in.nextInt();
			sum=sum+w[i];
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			w[i]=in.nextInt();
			sum=sum+w[i];
		} {
			w[i]=in.nextInt();
			sum=sum+w[i];
		} w[i]=in.nextInt() w[i] w i in.nextInt() in.nextInt in sum=sum+w[i] sum sum+w[i] sum w[i] w i int min=10000000; min 10000000 int leftsum=0; leftsum 0 for(int i=n-1;i>=0;i--)
		{
			sum=sum-w[i];
			leftsum=leftsum+w[i];
			int diff=Math.abs(sum-leftsum);
			if(min>diff)
				min=diff;
		} int i=n-1; int i=n-1; i n-1 n 1 i>=0 i 0 i-- i-- i {
			sum=sum-w[i];
			leftsum=leftsum+w[i];
			int diff=Math.abs(sum-leftsum);
			if(min>diff)
				min=diff;
		} {
			sum=sum-w[i];
			leftsum=leftsum+w[i];
			int diff=Math.abs(sum-leftsum);
			if(min>diff)
				min=diff;
		} sum=sum-w[i] sum sum-w[i] sum w[i] w i leftsum=leftsum+w[i] leftsum leftsum+w[i] leftsum w[i] w i int diff=Math.abs(sum-leftsum); diff Math.abs(sum-leftsum) Math.abs Math sum-leftsum sum leftsum if(min>diff)
				min=diff; min>diff min diff min=diff min diff 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 in=new Scanner(System.in);
		int n=in.nextInt();
		int sum=0;
		int [] w=new int [n];
		for(int i=0;i<n;i++)
		{
			w[i]=in.nextInt();
			sum=sum+w[i];
		}
		int min=10000000;
		int leftsum=0;
		for(int i=n-1;i>=0;i--)
		{
			sum=sum-w[i];
			leftsum=leftsum+w[i];
			int diff=Math.abs(sum-leftsum);
			if(min>diff)
				min=diff;
		}
		System.out.println(min);
	}
} public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int sum=0;
		int [] w=new int [n];
		for(int i=0;i<n;i++)
		{
			w[i]=in.nextInt();
			sum=sum+w[i];
		}
		int min=10000000;
		int leftsum=0;
		for(int i=n-1;i>=0;i--)
		{
			sum=sum-w[i];
			leftsum=leftsum+w[i];
			int diff=Math.abs(sum-leftsum);
			if(min>diff)
				min=diff;
		}
		System.out.println(min);
	}
} Main
import java.util.*;
import java.io.*;

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int sum=0;
		int [] w=new int [n];
		for(int i=0;i<n;i++)
		{
			w[i]=in.nextInt();
			sum=sum+w[i];
		}
		int min=10000000;
		int leftsum=0;
		for(int i=n-1;i>=0;i--)
		{
			sum=sum-w[i];
			leftsum=leftsum+w[i];
			int diff=Math.abs(sum-leftsum);
			if(min>diff)
				min=diff;
		}
		System.out.println(min);
	}
}
	