#include <bits/stdc++.h>
using namespace std;
int a[100005];
int idx[100005];
int cnt[100005] = {0};
int n, m;
int memo[100005];
int solve(int idx) {
  if (idx == n + 1) return 0;
  if (cnt[a[idx - 1]] == 1) {
    return memo[idx] = solve(idx + 1) + 1;
  } else {
    cnt[a[idx - 1]]--;
    return memo[idx] = solve(idx + 1);
  }
}
int main() {
  memset(memo, -1, sizeof memo);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  for (int i = 0; i < m; i++) {
    cin >> idx[i];
  }
  solve(1);
  for (int i = 0; i < m; i++) {
    cout << memo[idx[i]] << endl;
  }
}
