import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a[] = new int[n];
    int b[] = new int[n+1];
    int c[] = new int[n*(n+1)/2];
    int min = 100;
    for(int i=0 ; i<n ; i++){
      a[i] = sc.nextInt();
    }
    for(int i=0 ; i<n+1 ; i++){
      if(i==0){
        b[i] = 0;
      }else{
        b[i] = a[i-1] + b[i-1];
      }
    }
    // for (int i = 0; i < n+1; i++) {
    //   System.out.println(b[i]);
    // }
    for(int i=0 ; i<n ; i++){
      c[i] = b[n]-b[i];
      int x = Math.abs(c[i]-b[i]);
      min = Math.min(min,x);
    }
    // Arrays.sort(c);
    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 a[] = new int[n];
    int b[] = new int[n+1];
    int c[] = new int[n*(n+1)/2];
    int min = 100;
    for(int i=0 ; i<n ; i++){
      a[i] = sc.nextInt();
    }
    for(int i=0 ; i<n+1 ; i++){
      if(i==0){
        b[i] = 0;
      }else{
        b[i] = a[i-1] + b[i-1];
      }
    }
    // for (int i = 0; i < n+1; i++) {
    //   System.out.println(b[i]);
    // }
    for(int i=0 ; i<n ; i++){
      c[i] = b[n]-b[i];
      int x = Math.abs(c[i]-b[i]);
      min = Math.min(min,x);
    }
    // Arrays.sort(c);
    System.out.println(min);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a[] = new int[n];
    int b[] = new int[n+1];
    int c[] = new int[n*(n+1)/2];
    int min = 100;
    for(int i=0 ; i<n ; i++){
      a[i] = sc.nextInt();
    }
    for(int i=0 ; i<n+1 ; i++){
      if(i==0){
        b[i] = 0;
      }else{
        b[i] = a[i-1] + b[i-1];
      }
    }
    // for (int i = 0; i < n+1; i++) {
    //   System.out.println(b[i]);
    // }
    for(int i=0 ; i<n ; i++){
      c[i] = b[n]-b[i];
      int x = Math.abs(c[i]-b[i]);
      min = Math.min(min,x);
    }
    // Arrays.sort(c);
    System.out.println(min);
  } main {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a[] = new int[n];
    int b[] = new int[n+1];
    int c[] = new int[n*(n+1)/2];
    int min = 100;
    for(int i=0 ; i<n ; i++){
      a[i] = sc.nextInt();
    }
    for(int i=0 ; i<n+1 ; i++){
      if(i==0){
        b[i] = 0;
      }else{
        b[i] = a[i-1] + b[i-1];
      }
    }
    // for (int i = 0; i < n+1; i++) {
    //   System.out.println(b[i]);
    // }
    for(int i=0 ; i<n ; i++){
      c[i] = b[n]-b[i];
      int x = Math.abs(c[i]-b[i]);
      min = Math.min(min,x);
    }
    // Arrays.sort(c);
    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 a[] = new int[n]; a new int[n] n int b[] = new int[n+1]; b new int[n+1] n+1 n 1 int c[] = new int[n*(n+1)/2]; c new int[n*(n+1)/2] n*(n+1)/2 n*(n+1) n (n+1) n 1 2 int min = 100; min 100 for(int i=0 ; i<n ; i++){
      a[i] = sc.nextInt();
    } int i=0 ; int i=0 ; i 0 i<n i n i++ i++ i {
      a[i] = sc.nextInt();
    } {
      a[i] = sc.nextInt();
    } a[i] = sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc for(int i=0 ; i<n+1 ; i++){
      if(i==0){
        b[i] = 0;
      }else{
        b[i] = a[i-1] + b[i-1];
      }
    } int i=0 ; int i=0 ; i 0 i<n+1 i n+1 n 1 i++ i++ i {
      if(i==0){
        b[i] = 0;
      }else{
        b[i] = a[i-1] + b[i-1];
      }
    } {
      if(i==0){
        b[i] = 0;
      }else{
        b[i] = a[i-1] + b[i-1];
      }
    } if(i==0){
        b[i] = 0;
      }else{
        b[i] = a[i-1] + b[i-1];
      } i==0 i 0 {
        b[i] = 0;
      } b[i] = 0 b[i] b i 0 {
        b[i] = a[i-1] + b[i-1];
      } b[i] = a[i-1] + b[i-1] b[i] b i a[i-1] + b[i-1] a[i-1] a i-1 i 1 b[i-1] b i-1 i 1 for(int i=0 ; i<n ; i++){
      c[i] = b[n]-b[i];
      int x = Math.abs(c[i]-b[i]);
      min = Math.min(min,x);
    } int i=0 ; int i=0 ; i 0 i<n i n i++ i++ i {
      c[i] = b[n]-b[i];
      int x = Math.abs(c[i]-b[i]);
      min = Math.min(min,x);
    } {
      c[i] = b[n]-b[i];
      int x = Math.abs(c[i]-b[i]);
      min = Math.min(min,x);
    } c[i] = b[n]-b[i] c[i] c i b[n]-b[i] b[n] b n b[i] b i int x = Math.abs(c[i]-b[i]); x Math.abs(c[i]-b[i]) Math.abs Math c[i]-b[i] c[i] c i b[i] b i min = Math.min(min,x) min Math.min(min,x) Math.min Math min x 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 a[] = new int[n];
    int b[] = new int[n+1];
    int c[] = new int[n*(n+1)/2];
    int min = 100;
    for(int i=0 ; i<n ; i++){
      a[i] = sc.nextInt();
    }
    for(int i=0 ; i<n+1 ; i++){
      if(i==0){
        b[i] = 0;
      }else{
        b[i] = a[i-1] + b[i-1];
      }
    }
    // for (int i = 0; i < n+1; i++) {
    //   System.out.println(b[i]);
    // }
    for(int i=0 ; i<n ; i++){
      c[i] = b[n]-b[i];
      int x = Math.abs(c[i]-b[i]);
      min = Math.min(min,x);
    }
    // Arrays.sort(c);
    System.out.println(min);
  }
} public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a[] = new int[n];
    int b[] = new int[n+1];
    int c[] = new int[n*(n+1)/2];
    int min = 100;
    for(int i=0 ; i<n ; i++){
      a[i] = sc.nextInt();
    }
    for(int i=0 ; i<n+1 ; i++){
      if(i==0){
        b[i] = 0;
      }else{
        b[i] = a[i-1] + b[i-1];
      }
    }
    // for (int i = 0; i < n+1; i++) {
    //   System.out.println(b[i]);
    // }
    for(int i=0 ; i<n ; i++){
      c[i] = b[n]-b[i];
      int x = Math.abs(c[i]-b[i]);
      min = Math.min(min,x);
    }
    // Arrays.sort(c);
    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 a[] = new int[n];
    int b[] = new int[n+1];
    int c[] = new int[n*(n+1)/2];
    int min = 100;
    for(int i=0 ; i<n ; i++){
      a[i] = sc.nextInt();
    }
    for(int i=0 ; i<n+1 ; i++){
      if(i==0){
        b[i] = 0;
      }else{
        b[i] = a[i-1] + b[i-1];
      }
    }
    // for (int i = 0; i < n+1; i++) {
    //   System.out.println(b[i]);
    // }
    for(int i=0 ; i<n ; i++){
      c[i] = b[n]-b[i];
      int x = Math.abs(c[i]-b[i]);
      min = Math.min(min,x);
    }
    // Arrays.sort(c);
    System.out.println(min);
  }
}
