import java.util.Scanner;

/**
 * @author author
 *
 */
public class Main {

  /**
   * @param args
   */
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());

    int[] numbers = new int[n];
    for (int i = 0; i < n; i++) {
      numbers[i] = Integer.parseInt(sc.next());
    }
    
    int min = 12000;
    for (int k = 0; k < numbers.length; k++) {
      int sumRight = 0;
      int sumLeft = 0;
      for (int k2 = k + 1; k2 < numbers.length; k2++) {
        sumRight += numbers[k2];
      }
      for (int k3 = 0; k3 < k + 1; k3++) {
        sumLeft += numbers[k3];
      }
      min = Math.min(Math.abs(sumRight - sumLeft), min);
    }
    System.out.println(min);
  }
}
 import java.util.Scanner; Scanner java.util public class Main {

  /**
   * @param args
   */
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());

    int[] numbers = new int[n];
    for (int i = 0; i < n; i++) {
      numbers[i] = Integer.parseInt(sc.next());
    }
    
    int min = 12000;
    for (int k = 0; k < numbers.length; k++) {
      int sumRight = 0;
      int sumLeft = 0;
      for (int k2 = k + 1; k2 < numbers.length; k2++) {
        sumRight += numbers[k2];
      }
      for (int k3 = 0; k3 < k + 1; k3++) {
        sumLeft += numbers[k3];
      }
      min = Math.min(Math.abs(sumRight - sumLeft), min);
    }
    System.out.println(min);
  }
} Main /**
   * @param args
   */
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());

    int[] numbers = new int[n];
    for (int i = 0; i < n; i++) {
      numbers[i] = Integer.parseInt(sc.next());
    }
    
    int min = 12000;
    for (int k = 0; k < numbers.length; k++) {
      int sumRight = 0;
      int sumLeft = 0;
      for (int k2 = k + 1; k2 < numbers.length; k2++) {
        sumRight += numbers[k2];
      }
      for (int k3 = 0; k3 < k + 1; k3++) {
        sumLeft += numbers[k3];
      }
      min = Math.min(Math.abs(sumRight - sumLeft), min);
    }
    System.out.println(min);
  } main {

    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());

    int[] numbers = new int[n];
    for (int i = 0; i < n; i++) {
      numbers[i] = Integer.parseInt(sc.next());
    }
    
    int min = 12000;
    for (int k = 0; k < numbers.length; k++) {
      int sumRight = 0;
      int sumLeft = 0;
      for (int k2 = k + 1; k2 < numbers.length; k2++) {
        sumRight += numbers[k2];
      }
      for (int k3 = 0; k3 < k + 1; k3++) {
        sumLeft += numbers[k3];
      }
      min = Math.min(Math.abs(sumRight - sumLeft), min);
    }
    System.out.println(min);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int[] numbers = new int[n]; numbers new int[n] n for (int i = 0; i < n; i++) {
      numbers[i] = Integer.parseInt(sc.next());
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      numbers[i] = Integer.parseInt(sc.next());
    } {
      numbers[i] = Integer.parseInt(sc.next());
    } numbers[i] = Integer.parseInt(sc.next()) numbers[i] numbers i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int min = 12000; min 12000 for (int k = 0; k < numbers.length; k++) {
      int sumRight = 0;
      int sumLeft = 0;
      for (int k2 = k + 1; k2 < numbers.length; k2++) {
        sumRight += numbers[k2];
      }
      for (int k3 = 0; k3 < k + 1; k3++) {
        sumLeft += numbers[k3];
      }
      min = Math.min(Math.abs(sumRight - sumLeft), min);
    } int k = 0; int k = 0; k 0 k < numbers.length k numbers.length numbers numbers.length k++ k++ k {
      int sumRight = 0;
      int sumLeft = 0;
      for (int k2 = k + 1; k2 < numbers.length; k2++) {
        sumRight += numbers[k2];
      }
      for (int k3 = 0; k3 < k + 1; k3++) {
        sumLeft += numbers[k3];
      }
      min = Math.min(Math.abs(sumRight - sumLeft), min);
    } {
      int sumRight = 0;
      int sumLeft = 0;
      for (int k2 = k + 1; k2 < numbers.length; k2++) {
        sumRight += numbers[k2];
      }
      for (int k3 = 0; k3 < k + 1; k3++) {
        sumLeft += numbers[k3];
      }
      min = Math.min(Math.abs(sumRight - sumLeft), min);
    } int sumRight = 0; sumRight 0 int sumLeft = 0; sumLeft 0 for (int k2 = k + 1; k2 < numbers.length; k2++) {
        sumRight += numbers[k2];
      } int k2 = k + 1; int k2 = k + 1; k2 k + 1 k 1 k2 < numbers.length k2 numbers.length numbers numbers.length k2++ k2++ k2 {
        sumRight += numbers[k2];
      } {
        sumRight += numbers[k2];
      } sumRight += numbers[k2] sumRight numbers[k2] numbers k2 for (int k3 = 0; k3 < k + 1; k3++) {
        sumLeft += numbers[k3];
      } int k3 = 0; int k3 = 0; k3 0 k3 < k + 1 k3 k + 1 k 1 k3++ k3++ k3 {
        sumLeft += numbers[k3];
      } {
        sumLeft += numbers[k3];
      } sumLeft += numbers[k3] sumLeft numbers[k3] numbers k3 min = Math.min(Math.abs(sumRight - sumLeft), min) min Math.min(Math.abs(sumRight - sumLeft), min) Math.min Math Math.abs(sumRight - sumLeft) Math.abs Math sumRight - sumLeft sumRight sumLeft min System.out.println(min) System.out.println System.out System System.out min String[] args args public class Main {

  /**
   * @param args
   */
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());

    int[] numbers = new int[n];
    for (int i = 0; i < n; i++) {
      numbers[i] = Integer.parseInt(sc.next());
    }
    
    int min = 12000;
    for (int k = 0; k < numbers.length; k++) {
      int sumRight = 0;
      int sumLeft = 0;
      for (int k2 = k + 1; k2 < numbers.length; k2++) {
        sumRight += numbers[k2];
      }
      for (int k3 = 0; k3 < k + 1; k3++) {
        sumLeft += numbers[k3];
      }
      min = Math.min(Math.abs(sumRight - sumLeft), min);
    }
    System.out.println(min);
  }
} public class Main {

  /**
   * @param args
   */
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());

    int[] numbers = new int[n];
    for (int i = 0; i < n; i++) {
      numbers[i] = Integer.parseInt(sc.next());
    }
    
    int min = 12000;
    for (int k = 0; k < numbers.length; k++) {
      int sumRight = 0;
      int sumLeft = 0;
      for (int k2 = k + 1; k2 < numbers.length; k2++) {
        sumRight += numbers[k2];
      }
      for (int k3 = 0; k3 < k + 1; k3++) {
        sumLeft += numbers[k3];
      }
      min = Math.min(Math.abs(sumRight - sumLeft), min);
    }
    System.out.println(min);
  }
} Main
import java.util.Scanner;

/**
 * @author author
 *
 */
public class Main {

  /**
   * @param args
   */
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());

    int[] numbers = new int[n];
    for (int i = 0; i < n; i++) {
      numbers[i] = Integer.parseInt(sc.next());
    }
    
    int min = 12000;
    for (int k = 0; k < numbers.length; k++) {
      int sumRight = 0;
      int sumLeft = 0;
      for (int k2 = k + 1; k2 < numbers.length; k2++) {
        sumRight += numbers[k2];
      }
      for (int k3 = 0; k3 < k + 1; k3++) {
        sumLeft += numbers[k3];
      }
      min = Math.min(Math.abs(sumRight - sumLeft), min);
    }
    System.out.println(min);
  }
}

