#include <bits/stdc++.h>
using namespace std;
int ans[(int)1e5 + 20];
int main() {
  int n, m, x;
  vector<int> v;
  vector<pair<int, int> > q;
  cin >> n >> m;
  v.resize(n + 2);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  for (int j = 0; j < m; j++) {
    cin >> x;
    q.push_back(make_pair(x - 1, j));
  }
  sort(q.begin(), q.end(), greater<pair<int, int> >());
  int cur = n - 1;
  set<int> s;
  for (int i = 0; i < m; i++) {
    while (cur >= q[i].first) {
      s.insert(v[cur]);
      cur--;
    }
    ans[q[i].second] = s.size();
  }
  for (int i = 0; i < m; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}
