import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int[] b = new int[a];
    int sum = 0; 
    int ans = 0;
    for(int i = 0;i < b.length;i++){
      b[i] = sc.nextInt();
      sum += b[i];
    }
    for(int j = 1;j < b.length;j++){
      int half = 0;
      int tmp = 0;
      for(int x = 0;x < j;x++){
        half += b[x];
        tmp = sum - (half * 2);
        tmp = Math.abs(tmp);
        if(x == 0 ||tmp < ans){
          ans = tmp;
        }
      }
    }
    System.out.println(ans);
  }
} import java.util.Scanner; Scanner java.util public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int[] b = new int[a];
    int sum = 0; 
    int ans = 0;
    for(int i = 0;i < b.length;i++){
      b[i] = sc.nextInt();
      sum += b[i];
    }
    for(int j = 1;j < b.length;j++){
      int half = 0;
      int tmp = 0;
      for(int x = 0;x < j;x++){
        half += b[x];
        tmp = sum - (half * 2);
        tmp = Math.abs(tmp);
        if(x == 0 ||tmp < ans){
          ans = tmp;
        }
      }
    }
    System.out.println(ans);
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int[] b = new int[a];
    int sum = 0; 
    int ans = 0;
    for(int i = 0;i < b.length;i++){
      b[i] = sc.nextInt();
      sum += b[i];
    }
    for(int j = 1;j < b.length;j++){
      int half = 0;
      int tmp = 0;
      for(int x = 0;x < j;x++){
        half += b[x];
        tmp = sum - (half * 2);
        tmp = Math.abs(tmp);
        if(x == 0 ||tmp < ans){
          ans = tmp;
        }
      }
    }
    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int[] b = new int[a];
    int sum = 0; 
    int ans = 0;
    for(int i = 0;i < b.length;i++){
      b[i] = sc.nextInt();
      sum += b[i];
    }
    for(int j = 1;j < b.length;j++){
      int half = 0;
      int tmp = 0;
      for(int x = 0;x < j;x++){
        half += b[x];
        tmp = sum - (half * 2);
        tmp = Math.abs(tmp);
        if(x == 0 ||tmp < ans){
          ans = tmp;
        }
      }
    }
    System.out.println(ans);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int[] b = new int[a]; b new int[a] a int sum = 0; sum 0 int ans = 0; ans 0 for(int i = 0;i < b.length;i++){
      b[i] = sc.nextInt();
      sum += b[i];
    } int i = 0; int i = 0; i 0 i < b.length i b.length b b.length i++ i++ i {
      b[i] = sc.nextInt();
      sum += b[i];
    } {
      b[i] = sc.nextInt();
      sum += b[i];
    } b[i] = sc.nextInt() b[i] b i sc.nextInt() sc.nextInt sc sum += b[i] sum b[i] b i for(int j = 1;j < b.length;j++){
      int half = 0;
      int tmp = 0;
      for(int x = 0;x < j;x++){
        half += b[x];
        tmp = sum - (half * 2);
        tmp = Math.abs(tmp);
        if(x == 0 ||tmp < ans){
          ans = tmp;
        }
      }
    } int j = 1; int j = 1; j 1 j < b.length j b.length b b.length j++ j++ j {
      int half = 0;
      int tmp = 0;
      for(int x = 0;x < j;x++){
        half += b[x];
        tmp = sum - (half * 2);
        tmp = Math.abs(tmp);
        if(x == 0 ||tmp < ans){
          ans = tmp;
        }
      }
    } {
      int half = 0;
      int tmp = 0;
      for(int x = 0;x < j;x++){
        half += b[x];
        tmp = sum - (half * 2);
        tmp = Math.abs(tmp);
        if(x == 0 ||tmp < ans){
          ans = tmp;
        }
      }
    } int half = 0; half 0 int tmp = 0; tmp 0 for(int x = 0;x < j;x++){
        half += b[x];
        tmp = sum - (half * 2);
        tmp = Math.abs(tmp);
        if(x == 0 ||tmp < ans){
          ans = tmp;
        }
      } int x = 0; int x = 0; x 0 x < j x j x++ x++ x {
        half += b[x];
        tmp = sum - (half * 2);
        tmp = Math.abs(tmp);
        if(x == 0 ||tmp < ans){
          ans = tmp;
        }
      } {
        half += b[x];
        tmp = sum - (half * 2);
        tmp = Math.abs(tmp);
        if(x == 0 ||tmp < ans){
          ans = tmp;
        }
      } half += b[x] half b[x] b x tmp = sum - (half * 2) tmp sum - (half * 2) sum (half * 2) half 2 tmp = Math.abs(tmp) tmp Math.abs(tmp) Math.abs Math tmp if(x == 0 ||tmp < ans){
          ans = tmp;
        } x == 0 ||tmp < ans x == 0 x 0 tmp < ans tmp ans {
          ans = tmp;
        } ans = tmp ans tmp 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 a = sc.nextInt();
    int[] b = new int[a];
    int sum = 0; 
    int ans = 0;
    for(int i = 0;i < b.length;i++){
      b[i] = sc.nextInt();
      sum += b[i];
    }
    for(int j = 1;j < b.length;j++){
      int half = 0;
      int tmp = 0;
      for(int x = 0;x < j;x++){
        half += b[x];
        tmp = sum - (half * 2);
        tmp = Math.abs(tmp);
        if(x == 0 ||tmp < ans){
          ans = tmp;
        }
      }
    }
    System.out.println(ans);
  }
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int[] b = new int[a];
    int sum = 0; 
    int ans = 0;
    for(int i = 0;i < b.length;i++){
      b[i] = sc.nextInt();
      sum += b[i];
    }
    for(int j = 1;j < b.length;j++){
      int half = 0;
      int tmp = 0;
      for(int x = 0;x < j;x++){
        half += b[x];
        tmp = sum - (half * 2);
        tmp = Math.abs(tmp);
        if(x == 0 ||tmp < ans){
          ans = tmp;
        }
      }
    }
    System.out.println(ans);
  }
} Main
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int[] b = new int[a];
    int sum = 0; 
    int ans = 0;
    for(int i = 0;i < b.length;i++){
      b[i] = sc.nextInt();
      sum += b[i];
    }
    for(int j = 1;j < b.length;j++){
      int half = 0;
      int tmp = 0;
      for(int x = 0;x < j;x++){
        half += b[x];
        tmp = sum - (half * 2);
        tmp = Math.abs(tmp);
        if(x == 0 ||tmp < ans){
          ans = tmp;
        }
      }
    }
    System.out.println(ans);
  }
}