import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);

    int n,i,t,min,s1,s2;
    int w[];

    n = sc.nextInt();

    w = new int[n];

    for(i=0;i<n;i++){
      w[i] = sc.nextInt();
    }
    min = 99999;
    for(t=1;t<n;t++){
      s1=0;
      s2=0;
      for(i=0;i<t;i++){
        s1 += w[i];
      }
      for(;i<n;i++){
        s2 += w[i];
      }
      if(s1>s2){
        if(min>s1-s2){
          min = s1-s2;
        }
        
      }else{
        if(min>s2-s1){
          min = s2-s1;
        }
      }

    }
    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,i,t,min,s1,s2;
    int w[];

    n = sc.nextInt();

    w = new int[n];

    for(i=0;i<n;i++){
      w[i] = sc.nextInt();
    }
    min = 99999;
    for(t=1;t<n;t++){
      s1=0;
      s2=0;
      for(i=0;i<t;i++){
        s1 += w[i];
      }
      for(;i<n;i++){
        s2 += w[i];
      }
      if(s1>s2){
        if(min>s1-s2){
          min = s1-s2;
        }
        
      }else{
        if(min>s2-s1){
          min = s2-s1;
        }
      }

    }
    System.out.println(min);
  }
} Main public static void main(String[] args){
    Scanner sc =new Scanner(System.in);

    int n,i,t,min,s1,s2;
    int w[];

    n = sc.nextInt();

    w = new int[n];

    for(i=0;i<n;i++){
      w[i] = sc.nextInt();
    }
    min = 99999;
    for(t=1;t<n;t++){
      s1=0;
      s2=0;
      for(i=0;i<t;i++){
        s1 += w[i];
      }
      for(;i<n;i++){
        s2 += w[i];
      }
      if(s1>s2){
        if(min>s1-s2){
          min = s1-s2;
        }
        
      }else{
        if(min>s2-s1){
          min = s2-s1;
        }
      }

    }
    System.out.println(min);
  } main {
    Scanner sc =new Scanner(System.in);

    int n,i,t,min,s1,s2;
    int w[];

    n = sc.nextInt();

    w = new int[n];

    for(i=0;i<n;i++){
      w[i] = sc.nextInt();
    }
    min = 99999;
    for(t=1;t<n;t++){
      s1=0;
      s2=0;
      for(i=0;i<t;i++){
        s1 += w[i];
      }
      for(;i<n;i++){
        s2 += w[i];
      }
      if(s1>s2){
        if(min>s1-s2){
          min = s1-s2;
        }
        
      }else{
        if(min>s2-s1){
          min = s2-s1;
        }
      }

    }
    System.out.println(min);
  } Scanner sc =new Scanner(System.in); sc new Scanner(System.in) int n n i i t t min min s1 s1 s2; s2 int w[]; w n = sc.nextInt() n sc.nextInt() sc.nextInt sc w = new int[n] w new int[n] n for(i=0;i<n;i++){
      w[i] = sc.nextInt();
    } i=0; i=0 i 0 i<n i n i++ i++ i {
      w[i] = sc.nextInt();
    } {
      w[i] = sc.nextInt();
    } w[i] = sc.nextInt() w[i] w i sc.nextInt() sc.nextInt sc min = 99999 min 99999 for(t=1;t<n;t++){
      s1=0;
      s2=0;
      for(i=0;i<t;i++){
        s1 += w[i];
      }
      for(;i<n;i++){
        s2 += w[i];
      }
      if(s1>s2){
        if(min>s1-s2){
          min = s1-s2;
        }
        
      }else{
        if(min>s2-s1){
          min = s2-s1;
        }
      }

    } t=1; t=1 t 1 t<n t n t++ t++ t {
      s1=0;
      s2=0;
      for(i=0;i<t;i++){
        s1 += w[i];
      }
      for(;i<n;i++){
        s2 += w[i];
      }
      if(s1>s2){
        if(min>s1-s2){
          min = s1-s2;
        }
        
      }else{
        if(min>s2-s1){
          min = s2-s1;
        }
      }

    } {
      s1=0;
      s2=0;
      for(i=0;i<t;i++){
        s1 += w[i];
      }
      for(;i<n;i++){
        s2 += w[i];
      }
      if(s1>s2){
        if(min>s1-s2){
          min = s1-s2;
        }
        
      }else{
        if(min>s2-s1){
          min = s2-s1;
        }
      }

    } s1=0 s1 0 s2=0 s2 0 for(i=0;i<t;i++){
        s1 += w[i];
      } i=0; i=0 i 0 i<t i t i++ i++ i {
        s1 += w[i];
      } {
        s1 += w[i];
      } s1 += w[i] s1 w[i] w i for(;i<n;i++){
        s2 += w[i];
      } ; i<n i n i++ i++ i {
        s2 += w[i];
      } {
        s2 += w[i];
      } s2 += w[i] s2 w[i] w i if(s1>s2){
        if(min>s1-s2){
          min = s1-s2;
        }
        
      }else{
        if(min>s2-s1){
          min = s2-s1;
        }
      } s1>s2 s1 s2 {
        if(min>s1-s2){
          min = s1-s2;
        }
        
      } if(min>s1-s2){
          min = s1-s2;
        } min>s1-s2 min s1-s2 s1 s2 {
          min = s1-s2;
        } min = s1-s2 min s1-s2 s1 s2 {
        if(min>s2-s1){
          min = s2-s1;
        }
      } if(min>s2-s1){
          min = s2-s1;
        } min>s2-s1 min s2-s1 s2 s1 {
          min = s2-s1;
        } min = s2-s1 min s2-s1 s2 s1 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,i,t,min,s1,s2;
    int w[];

    n = sc.nextInt();

    w = new int[n];

    for(i=0;i<n;i++){
      w[i] = sc.nextInt();
    }
    min = 99999;
    for(t=1;t<n;t++){
      s1=0;
      s2=0;
      for(i=0;i<t;i++){
        s1 += w[i];
      }
      for(;i<n;i++){
        s2 += w[i];
      }
      if(s1>s2){
        if(min>s1-s2){
          min = s1-s2;
        }
        
      }else{
        if(min>s2-s1){
          min = s2-s1;
        }
      }

    }
    System.out.println(min);
  }
} public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);

    int n,i,t,min,s1,s2;
    int w[];

    n = sc.nextInt();

    w = new int[n];

    for(i=0;i<n;i++){
      w[i] = sc.nextInt();
    }
    min = 99999;
    for(t=1;t<n;t++){
      s1=0;
      s2=0;
      for(i=0;i<t;i++){
        s1 += w[i];
      }
      for(;i<n;i++){
        s2 += w[i];
      }
      if(s1>s2){
        if(min>s1-s2){
          min = s1-s2;
        }
        
      }else{
        if(min>s2-s1){
          min = s2-s1;
        }
      }

    }
    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,i,t,min,s1,s2;
    int w[];

    n = sc.nextInt();

    w = new int[n];

    for(i=0;i<n;i++){
      w[i] = sc.nextInt();
    }
    min = 99999;
    for(t=1;t<n;t++){
      s1=0;
      s2=0;
      for(i=0;i<t;i++){
        s1 += w[i];
      }
      for(;i<n;i++){
        s2 += w[i];
      }
      if(s1>s2){
        if(min>s1-s2){
          min = s1-s2;
        }
        
      }else{
        if(min>s2-s1){
          min = s2-s1;
        }
      }

    }
    System.out.println(min);
  }
}
