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

public class Main
{
  	int n, sum = 0;
  	int[] w;
  
    Main(Scanner in, PrintWriter out)
    {
      n = in.nextInt();
      w = new int[n];
      for (int i = 0; i < n; i++)
        sum += (w[i] = in.nextInt());
      int min = 1+sum;
      for (int i = 1; i < n; i++)
      {
        int s1 = 0;
        for (int j = 0; j < i; j++)
          s1 += w[j];
        min = Math.min(min, Math.abs((sum-s1)-s1));
      }
      out.println(min);
    }
	
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		new	Main(in, out);
		out.close();
	} 
} import java.util.*; util.* java import java.io.*; io.* java public class Main
{
  	int n, sum = 0;
  	int[] w;
  
    Main(Scanner in, PrintWriter out)
    {
      n = in.nextInt();
      w = new int[n];
      for (int i = 0; i < n; i++)
        sum += (w[i] = in.nextInt());
      int min = 1+sum;
      for (int i = 1; i < n; i++)
      {
        int s1 = 0;
        for (int j = 0; j < i; j++)
          s1 += w[j];
        min = Math.min(min, Math.abs((sum-s1)-s1));
      }
      out.println(min);
    }
	
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		new	Main(in, out);
		out.close();
	} 
} Main int n n sum = 0; sum 0 int[] w; w Main(Scanner in, PrintWriter out)
    {
      n = in.nextInt();
      w = new int[n];
      for (int i = 0; i < n; i++)
        sum += (w[i] = in.nextInt());
      int min = 1+sum;
      for (int i = 1; i < n; i++)
      {
        int s1 = 0;
        for (int j = 0; j < i; j++)
          s1 += w[j];
        min = Math.min(min, Math.abs((sum-s1)-s1));
      }
      out.println(min);
    } Main {
      n = in.nextInt();
      w = new int[n];
      for (int i = 0; i < n; i++)
        sum += (w[i] = in.nextInt());
      int min = 1+sum;
      for (int i = 1; i < n; i++)
      {
        int s1 = 0;
        for (int j = 0; j < i; j++)
          s1 += w[j];
        min = Math.min(min, Math.abs((sum-s1)-s1));
      }
      out.println(min);
    } n = in.nextInt() n in.nextInt() in.nextInt in w = new int[n] w new int[n] n for (int i = 0; i < n; i++)
        sum += (w[i] = in.nextInt()); int i = 0; int i = 0; i 0 i < n i n i++ i++ i sum += (w[i] = in.nextInt()); sum += (w[i] = in.nextInt()) sum (w[i] = in.nextInt()) w[i] w i in.nextInt() in.nextInt in int min = 1+sum; min 1+sum 1 sum for (int i = 1; i < n; i++)
      {
        int s1 = 0;
        for (int j = 0; j < i; j++)
          s1 += w[j];
        min = Math.min(min, Math.abs((sum-s1)-s1));
      } int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
        int s1 = 0;
        for (int j = 0; j < i; j++)
          s1 += w[j];
        min = Math.min(min, Math.abs((sum-s1)-s1));
      } {
        int s1 = 0;
        for (int j = 0; j < i; j++)
          s1 += w[j];
        min = Math.min(min, Math.abs((sum-s1)-s1));
      } int s1 = 0; s1 0 for (int j = 0; j < i; j++)
          s1 += w[j]; int j = 0; int j = 0; j 0 j < i j i j++ j++ j s1 += w[j]; s1 += w[j] s1 w[j] w j min = Math.min(min, Math.abs((sum-s1)-s1)) min Math.min(min, Math.abs((sum-s1)-s1)) Math.min Math min Math.abs((sum-s1)-s1) Math.abs Math (sum-s1)-s1 (sum-s1) sum s1 s1 out.println(min) out.println out min Scanner in in PrintWriter out out public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		new	Main(in, out);
		out.close();
	} main {
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		new	Main(in, out);
		out.close();
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) new	Main(in, out) out.close() out.close out String[] args args public class Main
{
  	int n, sum = 0;
  	int[] w;
  
    Main(Scanner in, PrintWriter out)
    {
      n = in.nextInt();
      w = new int[n];
      for (int i = 0; i < n; i++)
        sum += (w[i] = in.nextInt());
      int min = 1+sum;
      for (int i = 1; i < n; i++)
      {
        int s1 = 0;
        for (int j = 0; j < i; j++)
          s1 += w[j];
        min = Math.min(min, Math.abs((sum-s1)-s1));
      }
      out.println(min);
    }
	
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		new	Main(in, out);
		out.close();
	} 
} public class Main
{
  	int n, sum = 0;
  	int[] w;
  
    Main(Scanner in, PrintWriter out)
    {
      n = in.nextInt();
      w = new int[n];
      for (int i = 0; i < n; i++)
        sum += (w[i] = in.nextInt());
      int min = 1+sum;
      for (int i = 1; i < n; i++)
      {
        int s1 = 0;
        for (int j = 0; j < i; j++)
          s1 += w[j];
        min = Math.min(min, Math.abs((sum-s1)-s1));
      }
      out.println(min);
    }
	
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		new	Main(in, out);
		out.close();
	} 
} Main
import java.util.*;
import java.io.*;

public class Main
{
  	int n, sum = 0;
  	int[] w;
  
    Main(Scanner in, PrintWriter out)
    {
      n = in.nextInt();
      w = new int[n];
      for (int i = 0; i < n; i++)
        sum += (w[i] = in.nextInt());
      int min = 1+sum;
      for (int i = 1; i < n; i++)
      {
        int s1 = 0;
        for (int j = 0; j < i; j++)
          s1 += w[j];
        min = Math.min(min, Math.abs((sum-s1)-s1));
      }
      out.println(min);
    }
	
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		new	Main(in, out);
		out.close();
	} 
}
