import java.util.*;
public class Main{
  public static void main(String[] args){
   	Scanner sc = new Scanner(System.in);

    int N  = sc.nextInt();
    int[] re = new int[N];
    for(int i = 0;i<N;i++)
    {
    	  re[i] = sc.nextInt();
    }
    int sum =0;
    for(int i = 0;i<N;i++)
    {
    	  sum += re[i];
    }
    int hsum = 0;
    int min = sum;
    int ans = 0;
    for(int i = 1;i<N;i++)
    {
      hsum =0;
      for(int k = 0; k <=i;k++)
      {
          hsum+=re[k];
      }
      if(min > Math.abs(sum-2*hsum))
      {
       	min = Math.abs(sum-2*hsum);
      }
      else break;
    }

   	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[] re = new int[N];
    for(int i = 0;i<N;i++)
    {
    	  re[i] = sc.nextInt();
    }
    int sum =0;
    for(int i = 0;i<N;i++)
    {
    	  sum += re[i];
    }
    int hsum = 0;
    int min = sum;
    int ans = 0;
    for(int i = 1;i<N;i++)
    {
      hsum =0;
      for(int k = 0; k <=i;k++)
      {
          hsum+=re[k];
      }
      if(min > Math.abs(sum-2*hsum))
      {
       	min = Math.abs(sum-2*hsum);
      }
      else break;
    }

   	System.out.println(min);
 }
} Main public static void main(String[] args){
   	Scanner sc = new Scanner(System.in);

    int N  = sc.nextInt();
    int[] re = new int[N];
    for(int i = 0;i<N;i++)
    {
    	  re[i] = sc.nextInt();
    }
    int sum =0;
    for(int i = 0;i<N;i++)
    {
    	  sum += re[i];
    }
    int hsum = 0;
    int min = sum;
    int ans = 0;
    for(int i = 1;i<N;i++)
    {
      hsum =0;
      for(int k = 0; k <=i;k++)
      {
          hsum+=re[k];
      }
      if(min > Math.abs(sum-2*hsum))
      {
       	min = Math.abs(sum-2*hsum);
      }
      else break;
    }

   	System.out.println(min);
 } main {
   	Scanner sc = new Scanner(System.in);

    int N  = sc.nextInt();
    int[] re = new int[N];
    for(int i = 0;i<N;i++)
    {
    	  re[i] = sc.nextInt();
    }
    int sum =0;
    for(int i = 0;i<N;i++)
    {
    	  sum += re[i];
    }
    int hsum = 0;
    int min = sum;
    int ans = 0;
    for(int i = 1;i<N;i++)
    {
      hsum =0;
      for(int k = 0; k <=i;k++)
      {
          hsum+=re[k];
      }
      if(min > Math.abs(sum-2*hsum))
      {
       	min = Math.abs(sum-2*hsum);
      }
      else break;
    }

   	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[] re = new int[N]; re new int[N] N for(int i = 0;i<N;i++)
    {
    	  re[i] = sc.nextInt();
    } int i = 0; int i = 0; i 0 i<N i N i++ i++ i {
    	  re[i] = sc.nextInt();
    } {
    	  re[i] = sc.nextInt();
    } re[i] = sc.nextInt() re[i] re i sc.nextInt() sc.nextInt sc int sum =0; sum 0 for(int i = 0;i<N;i++)
    {
    	  sum += re[i];
    } int i = 0; int i = 0; i 0 i<N i N i++ i++ i {
    	  sum += re[i];
    } {
    	  sum += re[i];
    } sum += re[i] sum re[i] re i int hsum = 0; hsum 0 int min = sum; min sum int ans = 0; ans 0 for(int i = 1;i<N;i++)
    {
      hsum =0;
      for(int k = 0; k <=i;k++)
      {
          hsum+=re[k];
      }
      if(min > Math.abs(sum-2*hsum))
      {
       	min = Math.abs(sum-2*hsum);
      }
      else break;
    } int i = 1; int i = 1; i 1 i<N i N i++ i++ i {
      hsum =0;
      for(int k = 0; k <=i;k++)
      {
          hsum+=re[k];
      }
      if(min > Math.abs(sum-2*hsum))
      {
       	min = Math.abs(sum-2*hsum);
      }
      else break;
    } {
      hsum =0;
      for(int k = 0; k <=i;k++)
      {
          hsum+=re[k];
      }
      if(min > Math.abs(sum-2*hsum))
      {
       	min = Math.abs(sum-2*hsum);
      }
      else break;
    } hsum =0 hsum 0 for(int k = 0; k <=i;k++)
      {
          hsum+=re[k];
      } int k = 0; int k = 0; k 0 k <=i k i k++ k++ k {
          hsum+=re[k];
      } {
          hsum+=re[k];
      } hsum+=re[k] hsum re[k] re k if(min > Math.abs(sum-2*hsum))
      {
       	min = Math.abs(sum-2*hsum);
      }
      else break; min > Math.abs(sum-2*hsum) min Math.abs(sum-2*hsum) Math.abs Math sum-2*hsum sum 2*hsum 2 hsum {
       	min = Math.abs(sum-2*hsum);
      } min = Math.abs(sum-2*hsum) min Math.abs(sum-2*hsum) Math.abs Math sum-2*hsum sum 2*hsum 2 hsum break; 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[] re = new int[N];
    for(int i = 0;i<N;i++)
    {
    	  re[i] = sc.nextInt();
    }
    int sum =0;
    for(int i = 0;i<N;i++)
    {
    	  sum += re[i];
    }
    int hsum = 0;
    int min = sum;
    int ans = 0;
    for(int i = 1;i<N;i++)
    {
      hsum =0;
      for(int k = 0; k <=i;k++)
      {
          hsum+=re[k];
      }
      if(min > Math.abs(sum-2*hsum))
      {
       	min = Math.abs(sum-2*hsum);
      }
      else break;
    }

   	System.out.println(min);
 }
} public class Main{
  public static void main(String[] args){
   	Scanner sc = new Scanner(System.in);

    int N  = sc.nextInt();
    int[] re = new int[N];
    for(int i = 0;i<N;i++)
    {
    	  re[i] = sc.nextInt();
    }
    int sum =0;
    for(int i = 0;i<N;i++)
    {
    	  sum += re[i];
    }
    int hsum = 0;
    int min = sum;
    int ans = 0;
    for(int i = 1;i<N;i++)
    {
      hsum =0;
      for(int k = 0; k <=i;k++)
      {
          hsum+=re[k];
      }
      if(min > Math.abs(sum-2*hsum))
      {
       	min = Math.abs(sum-2*hsum);
      }
      else break;
    }

   	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[] re = new int[N];
    for(int i = 0;i<N;i++)
    {
    	  re[i] = sc.nextInt();
    }
    int sum =0;
    for(int i = 0;i<N;i++)
    {
    	  sum += re[i];
    }
    int hsum = 0;
    int min = sum;
    int ans = 0;
    for(int i = 1;i<N;i++)
    {
      hsum =0;
      for(int k = 0; k <=i;k++)
      {
          hsum+=re[k];
      }
      if(min > Math.abs(sum-2*hsum))
      {
       	min = Math.abs(sum-2*hsum);
      }
      else break;
    }

   	System.out.println(min);
 }
}