import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] W = new int[N];
    int total = 0, S1 = 0, S2 = 0, min = 10000;
    for (int i=0; i<N; i++) {
      W[i] = sc.nextInt();
      total += W[i];
    }
    for (int i=0; i<N; i++) {
      for (int j=0; j<i; j++) {
        S1 += W[j];
      }
      S2 = total - S1;
      min = Math.min(Math.abs(S1 - S2), min);
      S1 = 0; S2 = 0;
    }
    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[] W = new int[N];
    int total = 0, S1 = 0, S2 = 0, min = 10000;
    for (int i=0; i<N; i++) {
      W[i] = sc.nextInt();
      total += W[i];
    }
    for (int i=0; i<N; i++) {
      for (int j=0; j<i; j++) {
        S1 += W[j];
      }
      S2 = total - S1;
      min = Math.min(Math.abs(S1 - S2), min);
      S1 = 0; S2 = 0;
    }
    System.out.println(min); 
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] W = new int[N];
    int total = 0, S1 = 0, S2 = 0, min = 10000;
    for (int i=0; i<N; i++) {
      W[i] = sc.nextInt();
      total += W[i];
    }
    for (int i=0; i<N; i++) {
      for (int j=0; j<i; j++) {
        S1 += W[j];
      }
      S2 = total - S1;
      min = Math.min(Math.abs(S1 - S2), min);
      S1 = 0; S2 = 0;
    }
    System.out.println(min); 
  } main {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] W = new int[N];
    int total = 0, S1 = 0, S2 = 0, min = 10000;
    for (int i=0; i<N; i++) {
      W[i] = sc.nextInt();
      total += W[i];
    }
    for (int i=0; i<N; i++) {
      for (int j=0; j<i; j++) {
        S1 += W[j];
      }
      S2 = total - S1;
      min = Math.min(Math.abs(S1 - S2), min);
      S1 = 0; S2 = 0;
    }
    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[] W = new int[N]; W new int[N] N int total = 0 total 0 S1 = 0 S1 0 S2 = 0 S2 0 min = 10000; min 10000 for (int i=0; i<N; i++) {
      W[i] = sc.nextInt();
      total += W[i];
    } int i=0; int i=0; i 0 i<N i N i++ i++ i {
      W[i] = sc.nextInt();
      total += W[i];
    } {
      W[i] = sc.nextInt();
      total += W[i];
    } W[i] = sc.nextInt() W[i] W i sc.nextInt() sc.nextInt sc total += W[i] total W[i] W i for (int i=0; i<N; i++) {
      for (int j=0; j<i; j++) {
        S1 += W[j];
      }
      S2 = total - S1;
      min = Math.min(Math.abs(S1 - S2), min);
      S1 = 0; S2 = 0;
    } int i=0; int i=0; i 0 i<N i N i++ i++ i {
      for (int j=0; j<i; j++) {
        S1 += W[j];
      }
      S2 = total - S1;
      min = Math.min(Math.abs(S1 - S2), min);
      S1 = 0; S2 = 0;
    } {
      for (int j=0; j<i; j++) {
        S1 += W[j];
      }
      S2 = total - S1;
      min = Math.min(Math.abs(S1 - S2), min);
      S1 = 0; S2 = 0;
    } for (int j=0; j<i; j++) {
        S1 += W[j];
      } int j=0; int j=0; j 0 j<i j i j++ j++ j {
        S1 += W[j];
      } {
        S1 += W[j];
      } S1 += W[j] S1 W[j] W j S2 = total - S1 S2 total - S1 total S1 min = Math.min(Math.abs(S1 - S2), min) min Math.min(Math.abs(S1 - S2), min) Math.min Math Math.abs(S1 - S2) Math.abs Math S1 - S2 S1 S2 min S1 = 0 S1 0 S2 = 0 S2 0 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[] W = new int[N];
    int total = 0, S1 = 0, S2 = 0, min = 10000;
    for (int i=0; i<N; i++) {
      W[i] = sc.nextInt();
      total += W[i];
    }
    for (int i=0; i<N; i++) {
      for (int j=0; j<i; j++) {
        S1 += W[j];
      }
      S2 = total - S1;
      min = Math.min(Math.abs(S1 - S2), min);
      S1 = 0; S2 = 0;
    }
    System.out.println(min); 
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] W = new int[N];
    int total = 0, S1 = 0, S2 = 0, min = 10000;
    for (int i=0; i<N; i++) {
      W[i] = sc.nextInt();
      total += W[i];
    }
    for (int i=0; i<N; i++) {
      for (int j=0; j<i; j++) {
        S1 += W[j];
      }
      S2 = total - S1;
      min = Math.min(Math.abs(S1 - S2), min);
      S1 = 0; S2 = 0;
    }
    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[] W = new int[N];
    int total = 0, S1 = 0, S2 = 0, min = 10000;
    for (int i=0; i<N; i++) {
      W[i] = sc.nextInt();
      total += W[i];
    }
    for (int i=0; i<N; i++) {
      for (int j=0; j<i; j++) {
        S1 += W[j];
      }
      S2 = total - S1;
      min = Math.min(Math.abs(S1 - S2), min);
      S1 = 0; S2 = 0;
    }
    System.out.println(min); 
  }
}