import java.util.Scanner;
import java.util.Arrays;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int d;
    int sum = 0;
    int abssum ;
    int[] array = new int[n];
    for(int i=0; i<n; i++){
      d = sc.nextInt();
      sum += d;
      array[i] = d;
    }
    abssum = sum;
    for(int i=0; i<n; i++){
      sum = sum - 2 * array[i];
      if(sum<0){
        if(abssum<Math.abs(sum)){
          System.out.println(abssum);
          break;
        }else{
          System.out.println(Math.abs(sum));
          break;
        }
      }
      abssum = Math.abs(sum);
    }
  }
} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int d;
    int sum = 0;
    int abssum ;
    int[] array = new int[n];
    for(int i=0; i<n; i++){
      d = sc.nextInt();
      sum += d;
      array[i] = d;
    }
    abssum = sum;
    for(int i=0; i<n; i++){
      sum = sum - 2 * array[i];
      if(sum<0){
        if(abssum<Math.abs(sum)){
          System.out.println(abssum);
          break;
        }else{
          System.out.println(Math.abs(sum));
          break;
        }
      }
      abssum = Math.abs(sum);
    }
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int d;
    int sum = 0;
    int abssum ;
    int[] array = new int[n];
    for(int i=0; i<n; i++){
      d = sc.nextInt();
      sum += d;
      array[i] = d;
    }
    abssum = sum;
    for(int i=0; i<n; i++){
      sum = sum - 2 * array[i];
      if(sum<0){
        if(abssum<Math.abs(sum)){
          System.out.println(abssum);
          break;
        }else{
          System.out.println(Math.abs(sum));
          break;
        }
      }
      abssum = Math.abs(sum);
    }
  } main {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int d;
    int sum = 0;
    int abssum ;
    int[] array = new int[n];
    for(int i=0; i<n; i++){
      d = sc.nextInt();
      sum += d;
      array[i] = d;
    }
    abssum = sum;
    for(int i=0; i<n; i++){
      sum = sum - 2 * array[i];
      if(sum<0){
        if(abssum<Math.abs(sum)){
          System.out.println(abssum);
          break;
        }else{
          System.out.println(Math.abs(sum));
          break;
        }
      }
      abssum = Math.abs(sum);
    }
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int d; d int sum = 0; sum 0 int abssum ; abssum int[] array = new int[n]; array new int[n] n for(int i=0; i<n; i++){
      d = sc.nextInt();
      sum += d;
      array[i] = d;
    } int i=0; int i=0; i 0 i<n i n i++ i++ i {
      d = sc.nextInt();
      sum += d;
      array[i] = d;
    } {
      d = sc.nextInt();
      sum += d;
      array[i] = d;
    } d = sc.nextInt() d sc.nextInt() sc.nextInt sc sum += d sum d array[i] = d array[i] array i d abssum = sum abssum sum for(int i=0; i<n; i++){
      sum = sum - 2 * array[i];
      if(sum<0){
        if(abssum<Math.abs(sum)){
          System.out.println(abssum);
          break;
        }else{
          System.out.println(Math.abs(sum));
          break;
        }
      }
      abssum = Math.abs(sum);
    } int i=0; int i=0; i 0 i<n i n i++ i++ i {
      sum = sum - 2 * array[i];
      if(sum<0){
        if(abssum<Math.abs(sum)){
          System.out.println(abssum);
          break;
        }else{
          System.out.println(Math.abs(sum));
          break;
        }
      }
      abssum = Math.abs(sum);
    } {
      sum = sum - 2 * array[i];
      if(sum<0){
        if(abssum<Math.abs(sum)){
          System.out.println(abssum);
          break;
        }else{
          System.out.println(Math.abs(sum));
          break;
        }
      }
      abssum = Math.abs(sum);
    } sum = sum - 2 * array[i] sum sum - 2 * array[i] sum 2 * array[i] 2 array[i] array i if(sum<0){
        if(abssum<Math.abs(sum)){
          System.out.println(abssum);
          break;
        }else{
          System.out.println(Math.abs(sum));
          break;
        }
      } sum<0 sum 0 {
        if(abssum<Math.abs(sum)){
          System.out.println(abssum);
          break;
        }else{
          System.out.println(Math.abs(sum));
          break;
        }
      } if(abssum<Math.abs(sum)){
          System.out.println(abssum);
          break;
        }else{
          System.out.println(Math.abs(sum));
          break;
        } abssum<Math.abs(sum) abssum Math.abs(sum) Math.abs Math sum {
          System.out.println(abssum);
          break;
        } System.out.println(abssum) System.out.println System.out System System.out abssum break; {
          System.out.println(Math.abs(sum));
          break;
        } System.out.println(Math.abs(sum)) System.out.println System.out System System.out Math.abs(sum) Math.abs Math sum break; abssum = Math.abs(sum) abssum Math.abs(sum) Math.abs Math sum String[] args args public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int d;
    int sum = 0;
    int abssum ;
    int[] array = new int[n];
    for(int i=0; i<n; i++){
      d = sc.nextInt();
      sum += d;
      array[i] = d;
    }
    abssum = sum;
    for(int i=0; i<n; i++){
      sum = sum - 2 * array[i];
      if(sum<0){
        if(abssum<Math.abs(sum)){
          System.out.println(abssum);
          break;
        }else{
          System.out.println(Math.abs(sum));
          break;
        }
      }
      abssum = Math.abs(sum);
    }
  }
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int d;
    int sum = 0;
    int abssum ;
    int[] array = new int[n];
    for(int i=0; i<n; i++){
      d = sc.nextInt();
      sum += d;
      array[i] = d;
    }
    abssum = sum;
    for(int i=0; i<n; i++){
      sum = sum - 2 * array[i];
      if(sum<0){
        if(abssum<Math.abs(sum)){
          System.out.println(abssum);
          break;
        }else{
          System.out.println(Math.abs(sum));
          break;
        }
      }
      abssum = Math.abs(sum);
    }
  }
} Main
import java.util.Scanner;
import java.util.Arrays;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int d;
    int sum = 0;
    int abssum ;
    int[] array = new int[n];
    for(int i=0; i<n; i++){
      d = sc.nextInt();
      sum += d;
      array[i] = d;
    }
    abssum = sum;
    for(int i=0; i<n; i++){
      sum = sum - 2 * array[i];
      if(sum<0){
        if(abssum<Math.abs(sum)){
          System.out.println(abssum);
          break;
        }else{
          System.out.println(Math.abs(sum));
          break;
        }
      }
      abssum = Math.abs(sum);
    }
  }
}