import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(), sum = 0;
    int[] W = new int[N];
    for (int i = 0; i < N; i++) {
      W[i] = sc.nextInt();
      sum += W[i];
    }
    int ans = 1000000000;
    for (int i = 0, tmp = 0; i < N; i++) {
      tmp += W[i];
      ans = Math.min(ans, Math.abs(tmp * 2 - sum));
    }
    System.out.println(ans);
  }
} import java.util.*; util.* java public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(), sum = 0;
    int[] W = new int[N];
    for (int i = 0; i < N; i++) {
      W[i] = sc.nextInt();
      sum += W[i];
    }
    int ans = 1000000000;
    for (int i = 0, tmp = 0; i < N; i++) {
      tmp += W[i];
      ans = Math.min(ans, Math.abs(tmp * 2 - sum));
    }
    System.out.println(ans);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(), sum = 0;
    int[] W = new int[N];
    for (int i = 0; i < N; i++) {
      W[i] = sc.nextInt();
      sum += W[i];
    }
    int ans = 1000000000;
    for (int i = 0, tmp = 0; i < N; i++) {
      tmp += W[i];
      ans = Math.min(ans, Math.abs(tmp * 2 - sum));
    }
    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(), sum = 0;
    int[] W = new int[N];
    for (int i = 0; i < N; i++) {
      W[i] = sc.nextInt();
      sum += W[i];
    }
    int ans = 1000000000;
    for (int i = 0, tmp = 0; i < N; i++) {
      tmp += W[i];
      ans = Math.min(ans, Math.abs(tmp * 2 - sum));
    }
    System.out.println(ans);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt() N sc.nextInt() sc.nextInt sc sum = 0; sum 0 int[] W = new int[N]; W new int[N] N for (int i = 0; i < N; i++) {
      W[i] = sc.nextInt();
      sum += W[i];
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      W[i] = sc.nextInt();
      sum += W[i];
    } {
      W[i] = sc.nextInt();
      sum += W[i];
    } W[i] = sc.nextInt() W[i] W i sc.nextInt() sc.nextInt sc sum += W[i] sum W[i] W i int ans = 1000000000; ans 1000000000 for (int i = 0, tmp = 0; i < N; i++) {
      tmp += W[i];
      ans = Math.min(ans, Math.abs(tmp * 2 - sum));
    } int i = 0, tmp = 0; int i = 0 i 0 tmp = 0; tmp 0 i < N i N i++ i++ i {
      tmp += W[i];
      ans = Math.min(ans, Math.abs(tmp * 2 - sum));
    } {
      tmp += W[i];
      ans = Math.min(ans, Math.abs(tmp * 2 - sum));
    } tmp += W[i] tmp W[i] W i ans = Math.min(ans, Math.abs(tmp * 2 - sum)) ans Math.min(ans, Math.abs(tmp * 2 - sum)) Math.min Math ans Math.abs(tmp * 2 - sum) Math.abs Math tmp * 2 - sum tmp * 2 tmp 2 sum System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(), sum = 0;
    int[] W = new int[N];
    for (int i = 0; i < N; i++) {
      W[i] = sc.nextInt();
      sum += W[i];
    }
    int ans = 1000000000;
    for (int i = 0, tmp = 0; i < N; i++) {
      tmp += W[i];
      ans = Math.min(ans, Math.abs(tmp * 2 - sum));
    }
    System.out.println(ans);
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(), sum = 0;
    int[] W = new int[N];
    for (int i = 0; i < N; i++) {
      W[i] = sc.nextInt();
      sum += W[i];
    }
    int ans = 1000000000;
    for (int i = 0, tmp = 0; i < N; i++) {
      tmp += W[i];
      ans = Math.min(ans, Math.abs(tmp * 2 - sum));
    }
    System.out.println(ans);
  }
} Main
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(), sum = 0;
    int[] W = new int[N];
    for (int i = 0; i < N; i++) {
      W[i] = sc.nextInt();
      sum += W[i];
    }
    int ans = 1000000000;
    for (int i = 0, tmp = 0; i < N; i++) {
      tmp += W[i];
      ans = Math.min(ans, Math.abs(tmp * 2 - sum));
    }
    System.out.println(ans);
  }
}