import 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];    
    for (int i = 0; i < a; i++) {
      b[i] = sc.nextInt();
    }
    
    int min = 2147483647;
    for (int i = 0; i < a-1; i++) {
      int c = 0;
      int d = 0;
      for (int j = 0; j <= i; j++) {
        c += b[j];
      }
      for (int j = i + 1 ; j < a ; j++) {
        d += b[j];
      }
      if (c < d) {
        if (min > d - c) {
          min = d -c ;
        }
      } else {
        if ( min > c - d) {
          min = c - d;
        }
      }
    }
    
    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 a = sc.nextInt();
    
    int[] b = new int[a];    
    for (int i = 0; i < a; i++) {
      b[i] = sc.nextInt();
    }
    
    int min = 2147483647;
    for (int i = 0; i < a-1; i++) {
      int c = 0;
      int d = 0;
      for (int j = 0; j <= i; j++) {
        c += b[j];
      }
      for (int j = i + 1 ; j < a ; j++) {
        d += b[j];
      }
      if (c < d) {
        if (min > d - c) {
          min = d -c ;
        }
      } else {
        if ( min > c - d) {
          min = c - d;
        }
      }
    }
    
    System.out.println(min);
   
  }
} Main public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    
    int[] b = new int[a];    
    for (int i = 0; i < a; i++) {
      b[i] = sc.nextInt();
    }
    
    int min = 2147483647;
    for (int i = 0; i < a-1; i++) {
      int c = 0;
      int d = 0;
      for (int j = 0; j <= i; j++) {
        c += b[j];
      }
      for (int j = i + 1 ; j < a ; j++) {
        d += b[j];
      }
      if (c < d) {
        if (min > d - c) {
          min = d -c ;
        }
      } else {
        if ( min > c - d) {
          min = c - d;
        }
      }
    }
    
    System.out.println(min);
   
  } main {
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    
    int[] b = new int[a];    
    for (int i = 0; i < a; i++) {
      b[i] = sc.nextInt();
    }
    
    int min = 2147483647;
    for (int i = 0; i < a-1; i++) {
      int c = 0;
      int d = 0;
      for (int j = 0; j <= i; j++) {
        c += b[j];
      }
      for (int j = i + 1 ; j < a ; j++) {
        d += b[j];
      }
      if (c < d) {
        if (min > d - c) {
          min = d -c ;
        }
      } else {
        if ( min > c - d) {
          min = c - d;
        }
      }
    }
    
    System.out.println(min);
   
  } 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 for (int i = 0; i < a; i++) {
      b[i] = sc.nextInt();
    } int i = 0; int i = 0; i 0 i < a i a i++ i++ i {
      b[i] = sc.nextInt();
    } {
      b[i] = sc.nextInt();
    } b[i] = sc.nextInt() b[i] b i sc.nextInt() sc.nextInt sc int min = 2147483647; min 2147483647 for (int i = 0; i < a-1; i++) {
      int c = 0;
      int d = 0;
      for (int j = 0; j <= i; j++) {
        c += b[j];
      }
      for (int j = i + 1 ; j < a ; j++) {
        d += b[j];
      }
      if (c < d) {
        if (min > d - c) {
          min = d -c ;
        }
      } else {
        if ( min > c - d) {
          min = c - d;
        }
      }
    } int i = 0; int i = 0; i 0 i < a-1 i a-1 a 1 i++ i++ i {
      int c = 0;
      int d = 0;
      for (int j = 0; j <= i; j++) {
        c += b[j];
      }
      for (int j = i + 1 ; j < a ; j++) {
        d += b[j];
      }
      if (c < d) {
        if (min > d - c) {
          min = d -c ;
        }
      } else {
        if ( min > c - d) {
          min = c - d;
        }
      }
    } {
      int c = 0;
      int d = 0;
      for (int j = 0; j <= i; j++) {
        c += b[j];
      }
      for (int j = i + 1 ; j < a ; j++) {
        d += b[j];
      }
      if (c < d) {
        if (min > d - c) {
          min = d -c ;
        }
      } else {
        if ( min > c - d) {
          min = c - d;
        }
      }
    } int c = 0; c 0 int d = 0; d 0 for (int j = 0; j <= i; j++) {
        c += b[j];
      } int j = 0; int j = 0; j 0 j <= i j i j++ j++ j {
        c += b[j];
      } {
        c += b[j];
      } c += b[j] c b[j] b j for (int j = i + 1 ; j < a ; j++) {
        d += b[j];
      } int j = i + 1 ; int j = i + 1 ; j i + 1 i 1 j < a j a j++ j++ j {
        d += b[j];
      } {
        d += b[j];
      } d += b[j] d b[j] b j if (c < d) {
        if (min > d - c) {
          min = d -c ;
        }
      } else {
        if ( min > c - d) {
          min = c - d;
        }
      } c < d c d {
        if (min > d - c) {
          min = d -c ;
        }
      } if (min > d - c) {
          min = d -c ;
        } min > d - c min d - c d c {
          min = d -c ;
        } min = d -c min d -c d c {
        if ( min > c - d) {
          min = c - d;
        }
      } if ( min > c - d) {
          min = c - d;
        } min > c - d min c - d c d {
          min = c - d;
        } min = c - d min c - d c d 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 a = sc.nextInt();
    
    int[] b = new int[a];    
    for (int i = 0; i < a; i++) {
      b[i] = sc.nextInt();
    }
    
    int min = 2147483647;
    for (int i = 0; i < a-1; i++) {
      int c = 0;
      int d = 0;
      for (int j = 0; j <= i; j++) {
        c += b[j];
      }
      for (int j = i + 1 ; j < a ; j++) {
        d += b[j];
      }
      if (c < d) {
        if (min > d - c) {
          min = d -c ;
        }
      } else {
        if ( min > c - d) {
          min = c - d;
        }
      }
    }
    
    System.out.println(min);
   
  }
} public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    
    int[] b = new int[a];    
    for (int i = 0; i < a; i++) {
      b[i] = sc.nextInt();
    }
    
    int min = 2147483647;
    for (int i = 0; i < a-1; i++) {
      int c = 0;
      int d = 0;
      for (int j = 0; j <= i; j++) {
        c += b[j];
      }
      for (int j = i + 1 ; j < a ; j++) {
        d += b[j];
      }
      if (c < d) {
        if (min > d - c) {
          min = d -c ;
        }
      } else {
        if ( min > c - d) {
          min = c - d;
        }
      }
    }
    
    System.out.println(min);
   
  }
} Main
import 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];    
    for (int i = 0; i < a; i++) {
      b[i] = sc.nextInt();
    }
    
    int min = 2147483647;
    for (int i = 0; i < a-1; i++) {
      int c = 0;
      int d = 0;
      for (int j = 0; j <= i; j++) {
        c += b[j];
      }
      for (int j = i + 1 ; j < a ; j++) {
        d += b[j];
      }
      if (c < d) {
        if (min > d - c) {
          min = d -c ;
        }
      } else {
        if ( min > c - d) {
          min = c - d;
        }
      }
    }
    
    System.out.println(min);
   
  }
}