public void solve() throws IOException {
    int n = nextInt();
    int m = nextInt();
    int[] arr = new int[n];
    int[] counts = new int[n];
    for (int x = 0; x < n; x++)
      arr[x] = nextInt();
    HashSet<Integer> distinct = new HashSet<Integer>();
    for (int x = 0; x < n; x++) {
      distinct.add(arr[n - 1 - x]);
      counts[n - 1 - x] = distinct.size();
    }
    for (int x = 0; x < m; x++) {
      int l = nextInt();
      System.out.println(counts[l - 1]);
    }
  }