import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int w[] = new int[n];
    for(int i = 0; i < n; i++){
      w[i] = sc.nextInt();
    }
    int ans = 99999;
    for(int i = 0; i < n-1; i++){
      int l = 0;
      int r = 0;
      for(int j = 0; j <= i; j++){
        l += w[j];
      }
      for(int j = i+1; j < n; j++){
        r += w[j];
      }
      ans = Math.min(ans,Math.abs(l-r));
    }
    System.out.print(ans);
  }
} import java.util.*; util.* java class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int w[] = new int[n];
    for(int i = 0; i < n; i++){
      w[i] = sc.nextInt();
    }
    int ans = 99999;
    for(int i = 0; i < n-1; i++){
      int l = 0;
      int r = 0;
      for(int j = 0; j <= i; j++){
        l += w[j];
      }
      for(int j = i+1; j < n; j++){
        r += w[j];
      }
      ans = Math.min(ans,Math.abs(l-r));
    }
    System.out.print(ans);
  }
} Main public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int w[] = new int[n];
    for(int i = 0; i < n; i++){
      w[i] = sc.nextInt();
    }
    int ans = 99999;
    for(int i = 0; i < n-1; i++){
      int l = 0;
      int r = 0;
      for(int j = 0; j <= i; j++){
        l += w[j];
      }
      for(int j = i+1; j < n; j++){
        r += w[j];
      }
      ans = Math.min(ans,Math.abs(l-r));
    }
    System.out.print(ans);
  } main {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int w[] = new int[n];
    for(int i = 0; i < n; i++){
      w[i] = sc.nextInt();
    }
    int ans = 99999;
    for(int i = 0; i < n-1; i++){
      int l = 0;
      int r = 0;
      for(int j = 0; j <= i; j++){
        l += w[j];
      }
      for(int j = i+1; j < n; j++){
        r += w[j];
      }
      ans = Math.min(ans,Math.abs(l-r));
    }
    System.out.print(ans);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int w[] = new int[n]; w new int[n] n for(int i = 0; i < n; i++){
      w[i] = sc.nextInt();
    } int i = 0; int 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 int ans = 99999; ans 99999 for(int i = 0; i < n-1; i++){
      int l = 0;
      int r = 0;
      for(int j = 0; j <= i; j++){
        l += w[j];
      }
      for(int j = i+1; j < n; j++){
        r += w[j];
      }
      ans = Math.min(ans,Math.abs(l-r));
    } int i = 0; int i = 0; i 0 i < n-1 i n-1 n 1 i++ i++ i {
      int l = 0;
      int r = 0;
      for(int j = 0; j <= i; j++){
        l += w[j];
      }
      for(int j = i+1; j < n; j++){
        r += w[j];
      }
      ans = Math.min(ans,Math.abs(l-r));
    } {
      int l = 0;
      int r = 0;
      for(int j = 0; j <= i; j++){
        l += w[j];
      }
      for(int j = i+1; j < n; j++){
        r += w[j];
      }
      ans = Math.min(ans,Math.abs(l-r));
    } int l = 0; l 0 int r = 0; r 0 for(int j = 0; j <= i; j++){
        l += w[j];
      } int j = 0; int j = 0; j 0 j <= i j i j++ j++ j {
        l += w[j];
      } {
        l += w[j];
      } l += w[j] l w[j] w j for(int j = i+1; j < n; j++){
        r += w[j];
      } int j = i+1; int j = i+1; j i+1 i 1 j < n j n j++ j++ j {
        r += w[j];
      } {
        r += w[j];
      } r += w[j] r w[j] w j ans = Math.min(ans,Math.abs(l-r)) ans Math.min(ans,Math.abs(l-r)) Math.min Math ans Math.abs(l-r) Math.abs Math l-r l r System.out.print(ans) System.out.print System.out System System.out ans String args[] args
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int w[] = new int[n];
    for(int i = 0; i < n; i++){
      w[i] = sc.nextInt();
    }
    int ans = 99999;
    for(int i = 0; i < n-1; i++){
      int l = 0;
      int r = 0;
      for(int j = 0; j <= i; j++){
        l += w[j];
      }
      for(int j = i+1; j < n; j++){
        r += w[j];
      }
      ans = Math.min(ans,Math.abs(l-r));
    }
    System.out.print(ans);
  }
}
