import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  private Scanner sc;

  private void run() {
    sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int[] array = new int[N];

    int left = 0;
    int right = 0;

    int sum = 0;
    for (int i = 0; i < N; i++) {
      array[i] = Integer.parseInt(sc.next());
      sum += array[i];
    }

    left = 0;
    right = sum;

    int ans = Integer.MAX_VALUE;

    for (int i = 0; i < N; i++) {
      left += array[i];
      right -= array[i];

      if (Math.abs(left - right) < ans) {
        ans = Math.abs(left - right);
      }
    }

    System.out.println(ans);
  }
} import java.util.Scanner; Scanner java.util public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  private Scanner sc;

  private void run() {
    sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int[] array = new int[N];

    int left = 0;
    int right = 0;

    int sum = 0;
    for (int i = 0; i < N; i++) {
      array[i] = Integer.parseInt(sc.next());
      sum += array[i];
    }

    left = 0;
    right = sum;

    int ans = Integer.MAX_VALUE;

    for (int i = 0; i < N; i++) {
      left += array[i];
      right -= array[i];

      if (Math.abs(left - right) < ans) {
        ans = Math.abs(left - right);
      }
    }

    System.out.println(ans);
  }
} Main private Scanner sc; sc public static void main(String[] args) {
    new Main().run();
  } main {
    new Main().run();
  } new Main().run() new Main().run new Main() String[] args args private void run() {
    sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int[] array = new int[N];

    int left = 0;
    int right = 0;

    int sum = 0;
    for (int i = 0; i < N; i++) {
      array[i] = Integer.parseInt(sc.next());
      sum += array[i];
    }

    left = 0;
    right = sum;

    int ans = Integer.MAX_VALUE;

    for (int i = 0; i < N; i++) {
      left += array[i];
      right -= array[i];

      if (Math.abs(left - right) < ans) {
        ans = Math.abs(left - right);
      }
    }

    System.out.println(ans);
  } run {
    sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int[] array = new int[N];

    int left = 0;
    int right = 0;

    int sum = 0;
    for (int i = 0; i < N; i++) {
      array[i] = Integer.parseInt(sc.next());
      sum += array[i];
    }

    left = 0;
    right = sum;

    int ans = Integer.MAX_VALUE;

    for (int i = 0; i < N; i++) {
      left += array[i];
      right -= array[i];

      if (Math.abs(left - right) < ans) {
        ans = Math.abs(left - right);
      }
    }

    System.out.println(ans);
  } 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[] array = new int[N]; array new int[N] N int left = 0; left 0 int right = 0; right 0 int sum = 0; sum 0 for (int i = 0; i < N; i++) {
      array[i] = Integer.parseInt(sc.next());
      sum += array[i];
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      array[i] = Integer.parseInt(sc.next());
      sum += array[i];
    } {
      array[i] = Integer.parseInt(sc.next());
      sum += array[i];
    } array[i] = Integer.parseInt(sc.next()) array[i] array i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc sum += array[i] sum array[i] array i left = 0 left 0 right = sum right sum int ans = Integer.MAX_VALUE; ans Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int i = 0; i < N; i++) {
      left += array[i];
      right -= array[i];

      if (Math.abs(left - right) < ans) {
        ans = Math.abs(left - right);
      }
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      left += array[i];
      right -= array[i];

      if (Math.abs(left - right) < ans) {
        ans = Math.abs(left - right);
      }
    } {
      left += array[i];
      right -= array[i];

      if (Math.abs(left - right) < ans) {
        ans = Math.abs(left - right);
      }
    } left += array[i] left array[i] array i right -= array[i] right array[i] array i if (Math.abs(left - right) < ans) {
        ans = Math.abs(left - right);
      } Math.abs(left - right) < ans Math.abs(left - right) Math.abs Math left - right left right ans {
        ans = Math.abs(left - right);
      } ans = Math.abs(left - right) ans Math.abs(left - right) Math.abs Math left - right left right System.out.println(ans) System.out.println System.out System System.out ans public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  private Scanner sc;

  private void run() {
    sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int[] array = new int[N];

    int left = 0;
    int right = 0;

    int sum = 0;
    for (int i = 0; i < N; i++) {
      array[i] = Integer.parseInt(sc.next());
      sum += array[i];
    }

    left = 0;
    right = sum;

    int ans = Integer.MAX_VALUE;

    for (int i = 0; i < N; i++) {
      left += array[i];
      right -= array[i];

      if (Math.abs(left - right) < ans) {
        ans = Math.abs(left - right);
      }
    }

    System.out.println(ans);
  }
} public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  private Scanner sc;

  private void run() {
    sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int[] array = new int[N];

    int left = 0;
    int right = 0;

    int sum = 0;
    for (int i = 0; i < N; i++) {
      array[i] = Integer.parseInt(sc.next());
      sum += array[i];
    }

    left = 0;
    right = sum;

    int ans = Integer.MAX_VALUE;

    for (int i = 0; i < N; i++) {
      left += array[i];
      right -= array[i];

      if (Math.abs(left - right) < ans) {
        ans = Math.abs(left - right);
      }
    }

    System.out.println(ans);
  }
} Main
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  private Scanner sc;

  private void run() {
    sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int[] array = new int[N];

    int left = 0;
    int right = 0;

    int sum = 0;
    for (int i = 0; i < N; i++) {
      array[i] = Integer.parseInt(sc.next());
      sum += array[i];
    }

    left = 0;
    right = sum;

    int ans = Integer.MAX_VALUE;

    for (int i = 0; i < N; i++) {
      left += array[i];
      right -= array[i];

      if (Math.abs(left - right) < ans) {
        ans = Math.abs(left - right);
      }
    }

    System.out.println(ans);
  }
}
