#include <bits/stdc++.h>
using namespace std;
void charswap(char* a, char* b) {
  char t = *a;
  *a = *b;
  *b = t;
}
void charbubble(char array[], int n) {
  int i, j;
  bool swapped;
  for (i = 0; i < n - 1; i++) {
    swapped = false;
    for (j = 0; j < n - i - 1; j++) {
      if (array[j] > array[j + 1]) {
        charswap(&array[j], &array[j + 1]);
        swapped = true;
      }
    }
    if (swapped == false) break;
  }
}
void intswap(int* a, int* b) {
  int t = *a;
  *a = *b;
  *b = t;
}
void intbubble(int array[], int n) {
  int i, j;
  bool swapped;
  for (i = 0; i < n - 1; i++) {
    swapped = false;
    for (j = 0; j < n - i - 1; j++) {
      if (array[j] > array[j + 1]) {
        intswap(&array[j], &array[j + 1]);
        swapped = true;
      }
    }
    if (swapped == false) break;
  }
}
void longswap(long long* a, long long* b) {
  long long t = *a;
  *a = *b;
  *b = t;
}
void longbubble(long long array[], long long n) {
  long long i, j;
  bool swapped;
  for (i = 0; i < n - 1; i++) {
    swapped = false;
    for (j = 0; j < n - i - 1; j++) {
      if (array[j] > array[j + 1]) {
        longswap(&array[j], &array[j + 1]);
        swapped = true;
      }
    }
    if (swapped = false) break;
  }
}
void lowercase(char array[], int n) {
  for (int i = 0; i < n; i++) {
    if (array[i] < 97) array[i] = array[i] + 32;
  }
}
int intsmallest(int a, int b, int c) {
  return (a < b ? (a < c ? a : c) : (b < c ? b : c));
}
int intgreatest(int a, int b, int c) {
  return (a > b ? (a > c ? a : c) : (b > c ? b : c));
}
int factorial(int n) {
  if (n == 0)
    return 1;
  else
    return n * factorial(n - 1);
}
long long fact(long long n) {
  if (n == 0)
    return 1;
  else
    return n * fact(n - 1);
}
void strshiftleft(char array[], int index, int length) {
  int j;
  j = index;
  while (j < length) {
    if (array[j + 1] != '-') {
      array[j] = array[j + 1];
    }
    j++;
  }
}
long long fun(long long n) {
  {
    int i;
    for (i = 3; i <= n; i++) {
      if (n % i == 0)
        break;
      else
        i++;
    }
    return i;
  }
}
long long larger(long long a, long long b) { return (a > b ? a : b); }
long long smallerlong(long long a, long long b) { return (a < b ? a : b); }
int smallerint(int a, int b) { return (a < b ? a : b); }
int largerint(int a, int b) { return (a > b ? a : b); }
long long maxfreq(long long array[], long long n) {
  long long maxcount = 0;
  long long max;
  long long i = 0;
  while (i < n - 1) {
    long long count = 1;
    bool flag = true;
    while (flag == true) {
      if (array[i] == array[i + 1]) {
        count++;
        flag = true;
      } else {
        flag = false;
      }
      i++;
    }
    if (count > maxcount) {
      maxcount = count;
      max = array[i - 1];
    }
  }
  return max;
}
int intpartition(int array[], int low, int high) {
  int pivot = array[high];
  int i = low - 1;
  for (int j = low; j <= high - 1; j++) {
    if (array[j] < pivot) {
      i++;
      intswap(&array[i], &array[j]);
    }
  }
  intswap(&array[i + 1], &array[high]);
  return i + 1;
}
void intquick(int array[], int low, int high) {
  if (low < high) {
    int pi = intpartition(array, low, high);
    intquick(array, low, pi - 1);
    intquick(array, pi + 1, high);
  }
}
long long longpartition(long long array[], long long low, long long high) {
  long long pivot = array[high];
  long long i = low - 1;
  for (long long j = low; j <= high - 1; j++) {
    if (array[j] < pivot) {
      i++;
      longswap(&array[i], &array[j]);
    }
  }
  longswap(&array[i + 1], &array[high]);
  return i + 1;
}
void longquick(long long array[], long long low, long long high) {
  if (low < high) {
    long long pi = longpartition(array, low, high);
    longquick(array, low, pi - 1);
    longquick(array, pi + 1, high);
  }
}
long long longgreatest(long long a, long long b, long long c) {
  return (a > b ? (a > c ? a : c) : (b > c ? b : c));
}
bool primecheck(long long n) {
  bool flag = false;
  if (n == 2)
    return true;
  else if (n % 2 == 0)
    return false;
  else {
    for (long long i = 3; i <= n / 2; i = i + 2) {
      if (n % i == 0) {
        flag = true;
        break;
      }
    }
    if (flag == true)
      return false;
    else
      return true;
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  int array[n];
  bool a[100001] = {false};
  int b[n];
  for (int i = 0; i < n; i++) {
    cin >> array[i];
    a[array[i]] = true;
  }
  int k = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (a[array[i]] == true) {
      k++;
      b[i] = k;
      a[array[i]] = false;
    } else {
      b[i] = k;
    }
  }
  for (int i = 1; i <= m; i++) {
    int p;
    cin >> p;
    cout << b[p - 1] << endl;
  }
  return 0;
}

### Prompt

Construct a CPP code solution to the problem outlined:

Sereja has an array a, consisting of n integers a1, a2, ..., an. The boy cannot sit and do nothing, he decided to study an array. Sereja took a piece of paper and wrote out m integers l1, l2, ..., lm (1 ≤ li ≤ n). For each number li he wants to know how many distinct numbers are staying on the positions li, li + 1, ..., n. Formally, he want to find the number of distinct numbers among ali, ali + 1, ..., an.?

Sereja wrote out the necessary array elements but the array was so large and the boy was so pressed for time. Help him, find the answer for the described question for each li.

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 105). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 105) — the array elements.

Next m lines contain integers l1, l2, ..., lm. The i-th line contains integer li (1 ≤ li ≤ n).

Output

Print m lines — on the i-th line print the answer to the number li.

Examples

Input

10 10
1 2 3 4 1 2 3 4 100000 99999
1
2
3
4
5
6
7
8
9
10


Output

6
6
6
6
6
5
4
3
2
1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void charswap(char* a, char* b) {
  char t = *a;
  *a = *b;
  *b = t;
}
void charbubble(char array[], int n) {
  int i, j;
  bool swapped;
  for (i = 0; i < n - 1; i++) {
    swapped = false;
    for (j = 0; j < n - i - 1; j++) {
      if (array[j] > array[j + 1]) {
        charswap(&array[j], &array[j + 1]);
        swapped = true;
      }
    }
    if (swapped == false) break;
  }
}
void intswap(int* a, int* b) {
  int t = *a;
  *a = *b;
  *b = t;
}
void intbubble(int array[], int n) {
  int i, j;
  bool swapped;
  for (i = 0; i < n - 1; i++) {
    swapped = false;
    for (j = 0; j < n - i - 1; j++) {
      if (array[j] > array[j + 1]) {
        intswap(&array[j], &array[j + 1]);
        swapped = true;
      }
    }
    if (swapped == false) break;
  }
}
void longswap(long long* a, long long* b) {
  long long t = *a;
  *a = *b;
  *b = t;
}
void longbubble(long long array[], long long n) {
  long long i, j;
  bool swapped;
  for (i = 0; i < n - 1; i++) {
    swapped = false;
    for (j = 0; j < n - i - 1; j++) {
      if (array[j] > array[j + 1]) {
        longswap(&array[j], &array[j + 1]);
        swapped = true;
      }
    }
    if (swapped = false) break;
  }
}
void lowercase(char array[], int n) {
  for (int i = 0; i < n; i++) {
    if (array[i] < 97) array[i] = array[i] + 32;
  }
}
int intsmallest(int a, int b, int c) {
  return (a < b ? (a < c ? a : c) : (b < c ? b : c));
}
int intgreatest(int a, int b, int c) {
  return (a > b ? (a > c ? a : c) : (b > c ? b : c));
}
int factorial(int n) {
  if (n == 0)
    return 1;
  else
    return n * factorial(n - 1);
}
long long fact(long long n) {
  if (n == 0)
    return 1;
  else
    return n * fact(n - 1);
}
void strshiftleft(char array[], int index, int length) {
  int j;
  j = index;
  while (j < length) {
    if (array[j + 1] != '-') {
      array[j] = array[j + 1];
    }
    j++;
  }
}
long long fun(long long n) {
  {
    int i;
    for (i = 3; i <= n; i++) {
      if (n % i == 0)
        break;
      else
        i++;
    }
    return i;
  }
}
long long larger(long long a, long long b) { return (a > b ? a : b); }
long long smallerlong(long long a, long long b) { return (a < b ? a : b); }
int smallerint(int a, int b) { return (a < b ? a : b); }
int largerint(int a, int b) { return (a > b ? a : b); }
long long maxfreq(long long array[], long long n) {
  long long maxcount = 0;
  long long max;
  long long i = 0;
  while (i < n - 1) {
    long long count = 1;
    bool flag = true;
    while (flag == true) {
      if (array[i] == array[i + 1]) {
        count++;
        flag = true;
      } else {
        flag = false;
      }
      i++;
    }
    if (count > maxcount) {
      maxcount = count;
      max = array[i - 1];
    }
  }
  return max;
}
int intpartition(int array[], int low, int high) {
  int pivot = array[high];
  int i = low - 1;
  for (int j = low; j <= high - 1; j++) {
    if (array[j] < pivot) {
      i++;
      intswap(&array[i], &array[j]);
    }
  }
  intswap(&array[i + 1], &array[high]);
  return i + 1;
}
void intquick(int array[], int low, int high) {
  if (low < high) {
    int pi = intpartition(array, low, high);
    intquick(array, low, pi - 1);
    intquick(array, pi + 1, high);
  }
}
long long longpartition(long long array[], long long low, long long high) {
  long long pivot = array[high];
  long long i = low - 1;
  for (long long j = low; j <= high - 1; j++) {
    if (array[j] < pivot) {
      i++;
      longswap(&array[i], &array[j]);
    }
  }
  longswap(&array[i + 1], &array[high]);
  return i + 1;
}
void longquick(long long array[], long long low, long long high) {
  if (low < high) {
    long long pi = longpartition(array, low, high);
    longquick(array, low, pi - 1);
    longquick(array, pi + 1, high);
  }
}
long long longgreatest(long long a, long long b, long long c) {
  return (a > b ? (a > c ? a : c) : (b > c ? b : c));
}
bool primecheck(long long n) {
  bool flag = false;
  if (n == 2)
    return true;
  else if (n % 2 == 0)
    return false;
  else {
    for (long long i = 3; i <= n / 2; i = i + 2) {
      if (n % i == 0) {
        flag = true;
        break;
      }
    }
    if (flag == true)
      return false;
    else
      return true;
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  int array[n];
  bool a[100001] = {false};
  int b[n];
  for (int i = 0; i < n; i++) {
    cin >> array[i];
    a[array[i]] = true;
  }
  int k = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (a[array[i]] == true) {
      k++;
      b[i] = k;
      a[array[i]] = false;
    } else {
      b[i] = k;
    }
  }
  for (int i = 1; i <= m; i++) {
    int p;
    cin >> p;
    cout << b[p - 1] << endl;
  }
  return 0;
}

```