Sereja has an array a, consisting of n integers a_1, a_2, ..., a_{n}. The boy cannot sit and do nothing, he decided to study an array. Sereja took a piece of paper and wrote out m integers l_1, l_2, ..., l_{m} (1 ≤ l_{i} ≤ n). For each number l_{i} he wants to know how many distinct numbers are staying on the positions l_{i}, l_{i} + 1, ..., n. Formally, he want to find the number of distinct numbers among a_{l}_{i}, a_{l}_{i} + 1, ..., a_{n}.?

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 l_{i}.


-----Input-----

The first line contains two integers n and m (1 ≤ n, m ≤ 10^5). The second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^5) — the array elements.

Next m lines contain integers l_1, l_2, ..., l_{m}. The i-th line contains integer l_{i} (1 ≤ l_{i} ≤ n).


-----Output-----

Print m lines — on the i-th line print the answer to the number l_{i}.


-----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

Source: codeforces | Difficulty: EASY
Tags: Dynamic programming

Data structures


Solutions:
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
s = set()
for i in range(n - 1, -1, -1):
	s.add(a[i])
	a[i] = str(len(s))
print('\n'.join([a[int(input()) - 1] for _ in range(m)]))


(n, m) = [int(j) for j in input().split()]
nums = [int(j) for j in input().split()]
(freq, ref) = (100000 * [0], n * [0])
count = 0
for j in range(n - 1, -1, -1):
	if freq[nums[j] - 1] == 0:
		count += 1
	freq[nums[j] - 1] += 1
	ref[j] = count
for j in range(m):
	l = int(input())
	print(ref[l - 1])


(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
l = [int(input()) for i in range(m)]
ans = [0] * n
s = set()
for i in range(n - 1, -1, -1):
	s.add(a[i])
	ans[i] = len(s)
for i in range(m):
	print(ans[l[i] - 1])


from collections import Counter
inp = lambda : map(int, input().rstrip().split())
(n, m) = inp()
a = list(inp())
dp = [0] * (n + 1)
c = Counter()
for i in range(n - 1, -1, -1):
	if c[a[i]] == 0:
		dp[i] = dp[i + 1] + 1
	else:
		dp[i] = dp[i + 1]
	c[a[i]] += 1
for _ in range(m):
	l = int(input())
	print(dp[l - 1])


while True:
	try:
		(n, m) = map(int, input().strip().split())
		list = [i for i in map(int, input().strip().split())]
		ai = []
		for i in range(m):
			ai.append(int(input()))
		dict = {}
		res = []
		j = len(list) - 1
		while j >= 0:
			if dict.get(list[j], 0) == 0:
				dict[list[j]] = 1
			res.append(len(dict))
			j -= 1
		for k in ai:
			print(res[-k])
	except:
		break


(n, m) = (int(i) for i in input().split())
rez = []
d = {}
nr = 0
for i in reversed(input().split()):
	if i in d.keys():
		d[i] += 1
		rez.append(nr)
	else:
		d[i] = 1
		nr += 1
		rez.append(nr)
for i in range(m):
	k = int(input())
	print(rez[n - k])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
seen = [0] * 100001
ans = [0]
a = a[::-1]
for i in range(n):
	ans.append(ans[-1])
	if not seen[a[i]]:
		seen[a[i]] = 1
		ans[-1] += 1
answer = ''
for i in range(m):
	answer += str(ans[-int(input())]) + '\n'
print(answer)


(n, m) = map(int, input().split())
a = [int(x) for x in input().split()][::-1]
s = set()
res = []
for x in a:
	s.add(x)
	res.append(str(len(s)))
print('\n'.join((res[n - int(input())] for x in range(m))))


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
(n, m) = zzz()
l = zzz()
ans = []
li = set()
for i in range(1, n + 1):
	x = l[-i]
	li.add(x)
	ans.append(len(li))
for _ in range(m):
	print(ans[n - int(z())])


from collections import defaultdict

def main():
	(n, m) = map(int, input().split())
	a_list = list(map(int, input().split()))
	dp = [0] * n
	dp[-1] = 1
	now_set = set()
	now_set.add(a_list[-1])
	for i in range(n - 2, -1, -1):
		dp[i] = dp[i + 1] + (a_list[i] not in now_set)
		now_set.add(a_list[i])
	ans_list = []
	for _ in range(m):
		l = int(input()) - 1
		ans_list.append(dp[l])
	print(*ans_list, sep='\n')
main()


def CF368B():
	(m, n) = map(int, input().split())
	nums = tuple(map(int, input().split()))
	queries = [int(input()) for _ in range(n)]
	counter = {}
	for num in nums:
		counter[num] = counter.get(num, 0) + 1
	keys = set(counter.keys())
	ans = {1: len(keys)}
	for i in range(max(queries)):
		x = nums[i]
		counter[x] -= 1
		ans[i + 1] = len(keys)
		if counter[x] == 0:
			keys.remove(x)
	res = [ans[i] for i in queries]
	return res
res = CF368B()
for num in res:
	print(num)


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
nums = set()
memo = [0] * (n + 1)
for j in range(n - 1, -1, -1):
	nums.add(l[j])
	memo[j + 1] = len(nums)
for i in range(m):
	index = int(input())
	print(memo[index])


(n, m) = list(map(int, input().split()))
arr = list(map(int, input().split()))
isFound = [False] * (10 ** 5 + 2)
res = [0] * (n + 2)
c = 0
for i in range(n - 1, -1, -1):
	if not isFound[arr[i]]:
		isFound[arr[i]] = True
		c += 1
	res[i + 1] = c
for _ in range(m):
	print(res[int(input())])


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return list(map(int, input().split()))

def solve(n, arr):
	dp = [[0]] * n
	s = set()
	s.add(arr[-1])
	dp[-1] = [1, s]
	for i in range(n - 2, -1, -1):
		count = dp[i + 1][0] + 1
		prev_set = dp[i + 1][1]
		if arr[i] in prev_set:
			count -= 1
		prev_set.add(arr[i])
		dp[i] = [count, prev_set]
	return dp
nm = inlt()
n_arr = inlt()
m_arr = []
for i in range(nm[1]):
	m_arr.append(inp())
dp = solve(nm[0], n_arr)
for i in range(nm[1]):
	print(dp[m_arr[i] - 1][0])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
s = set()
M = [list(map(int, input().split())) for i in range(m)]
for i in range(n - 1, -1, -1):
	s.add(a[i])
	a[i] = str(len(s))
for i in range(m):
	print(a[M[i][0] - 1])


from sys import stdin, stdout
input = stdin.readline
print = stdout.write
(n, m) = map(int, input().split())
arr = [int(x) for x in input().split()]
cnt = set()
diffcnt = [0] * (n + 1)
for i in range(n - 1, -1, -1):
	if arr[i] not in cnt:
		cnt.add(arr[i])
		diffcnt[i] = diffcnt[i + 1] + 1
	else:
		diffcnt[i] = diffcnt[i + 1]
for _ in range(m):
	x = int(input())
	print('%d\n' % diffcnt[x - 1])


from sys import stdin, stdout
input = stdin.readline
(n, m) = map(int, input().split())
ar = list(map(int, input().split()))
d = {}
ans = [0] * n
t = 0
for i in range(n - 1, -1, -1):
	if d.get(ar[i]) == None:
		d[ar[i]] = 1
		t += 1
	ans[i] = t
for i in range(m):
	x = int(input())
	print(ans[x - 1])


(n, m) = map(int, input().split())
lista = list(map(int, input().split()))
conjunto = set()
dic = {}
for i in reversed(range(len(lista))):
	conjunto.add(lista[i])
	lista[i] = len(conjunto)
for i in range(m):
	w = int(input())
	print(lista[w - 1])


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
v = 0
ans = [0] * n
dic = {}
for i in range(n - 1, -1, -1):
	if arr[i] in dic:
		ans[i] = v
	else:
		dic[arr[i]] = 1
		v += 1
		ans[i] = v
for i in range(m):
	a = int(input())
	print(ans[a - 1])


from sys import stdin
(n, m) = [int(x) for x in stdin.readline().split()]
arr = [int(x) for x in stdin.readline().split()]
l = [False] * (10 ** 5 + 1)
ans = [0] * (n + 1)
for i in range(n - 1, -1, -1):
	ans[i] = ans[i + 1]
	if l[arr[i]] == False:
		l[arr[i]] = True
		ans[i] += 1
for _ in range(m):
	print(ans[int(stdin.readline()) - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
dp = [0] * (n + 1)
cnt = set()
l = []
for _ in range(m):
	k = int(input())
	l.append(k)
for end in range(n - 1, -1, -1):
	cnt.add(a[end])
	dp[end] = len(cnt)
for num in l:
	print(dp[num - 1])


(n, m) = map(int, input().split())
a = [int(x) for x in input().split()]
l = []
for i in range(m):
	l.append(int(input()))
dp = [0] * n
jud = set()
j = 0
for i in reversed(a):
	if i not in jud:
		jud.add(i)
	j += 1
	dp[-j] = len(jud)
for i in range(m):
	print(dp[l[i] - 1])


I = lambda : map(int, input().split())
(n, m) = I()
a = input().split()
Tmp = dict()
res = [0] * n
c = 0
for i in range(n - 1, -1, -1):
	if Tmp.get(a[i], -1) == -1:
		Tmp[a[i]] = 1
		c += 1
		res[i] = c
	else:
		res[i] = c
for i in range(m):
	I = int(input())
	print(res[I - 1])


import sys
inf = float('inf')
mod = 1000000007

def get_array():
	return list(map(int, sys.stdin.readline().split()))

def get_ints():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline()

def main():
	(n, m) = get_ints()
	arr = get_array()
	d = {}
	d[arr[-1]] = 1
	ans = [1] * n
	for i in range(n - 2, -1, -1):
		x = arr[i]
		if x not in d:
			d[x] = 1
			ans[i] = 1 + ans[i + 1]
		else:
			ans[i] = ans[i + 1]
	for i in range(m):
		print(ans[int(input()) - 1])
main()


import sys

def __starting_point():
	(n, m) = [int(i) for i in sys.stdin.readline().rstrip().split(' ')]
	a = [int(i) for i in sys.stdin.readline().rstrip().split(' ')]
	l = [None] * m
	for i in range(m):
		l[i] = int(sys.stdin.readline().rstrip())
	l_sorted = sorted(l)
	l_order = sorted(range(m), key=lambda k: l[k])
	l_rank = sorted(range(m), key=lambda k: l_order[k])
	unique_elem = [None] * m
	for i in range(m):
		unique_elem[i] = set(a[l_sorted[i] - 1:l_sorted[i + 1] - 1]) if i < m - 1 else set(a[l_sorted[i] - 1:n])
	unique_elem_cumulative = unique_elem[-1]
	unique_elem_cumulative_count = [None] * m
	unique_elem_cumulative_count[-1] = len(unique_elem[-1])
	for i in range(m - 1):
		i_rev = m - i - 2
		unique_elem_cumulative |= unique_elem[i_rev]
		unique_elem_cumulative_count[i_rev] = len(unique_elem_cumulative)
	for i in range(m):
		idx = l_rank[i]
		print(unique_elem_cumulative_count[idx])
__starting_point()


def prep_(a):
	al = len(a)
	dic = {a[al - 1]: 1}
	a[al - 1] = dic
	for k in range(al - 2, -1, -1):
		if a[k] not in dic:
			dic = a[k + 1].copy()
			dic[a[k]] = 1
			a[k] = dic
		else:
			a[k] = a[k + 1]
		a[k + 1] = len(a[k + 1])
	a[0] = len(a[0])
	return a

def prep(a):
	al = len(a)
	dic = {a[al - 1]: 1}
	a[al - 1] = dic
	for k in range(al - 2, -1, -1):
		dl = len(a[k + 1])
		ak = a[k]
		a[k] = a[k + 1]
		a[k + 1] = dl
		if ak not in a[k]:
			a[k][ak] = 1
	a[0] = len(a[0])
	return a

def solve(a, m):
	return a[m - 1]

def main():
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a = prep(a)
	for k in range(m):
		l = int(input())
		print(solve(a, l))

def test():
	print(solve(prep([1, 2, 3, 4, 1, 2, 3, 4, 100000, 99999]), 1))
main()


import collections as cc
import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(n, m) = I()
l = I()
temp = []
f = cc.defaultdict(int)
k = 0
for i in l[::-1]:
	if not f[i]:
		k += 1
		f[i] += 1
		temp.append(k)
	else:
		temp.append(k)
temp = temp[::-1]
for i in range(m):
	(x,) = I()
	x -= 1
	print(temp[x])


def main():
	vistFlag = [0] * 100001
	inputLine = input()
	(n, m) = inputLine.split()
	nNumsLine = list(map(int, input().split()))
	resultList = []
	a = []
	for i in range(int(m)):
		a.append(int(input()))
	cnt = 0
	for i in range(int(n)):
		if vistFlag[nNumsLine[int(n) - 1 - i] - 1] == 0:
			cnt += 1
			vistFlag[nNumsLine[int(n) - 1 - i] - 1] = 1
		resultList.append(cnt)
	for i in a:
		print(resultList[int(n) - i])
main()


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
ans = [0] * (10 ** 5 + 1)
ans[l[-1]] = l[-1]
arr = [0] * n
arr[-1] = 1
for i in range(n - 2, -1, -1):
	if ans[l[i]] == 0:
		ans[l[i]] = l[i]
		arr[i] = arr[i + 1] + 1
	else:
		arr[i] = arr[i + 1]
for i in range(m):
	print(arr[int(input()) - 1])


(n, m) = input().split()
n = int(n)
m = int(m)
l = list(map(int, input().split()))
dp = [0] * n
i = n - 2
dp[n - 1] = 1
dict1 = {l[n - 1]: 1}
while i >= 0:
	if l[i] in dict1:
		dp[i] = dp[i + 1]
	else:
		dict1[l[i]] = 1
		dp[i] = dp[i + 1] + 1
	i -= 1
for i in range(m):
	a = int(input())
	print(dp[a - 1])


from collections import defaultdict
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
s = set()
b = [0] * n
for i in range(n - 1, -1, -1):
	s.add(a[i])
	b[i] = len(s)
for i in range(m):
	c = int(input())
	print(' ', b[c - 1])


from collections import defaultdict
(n, m) = [int(i) for i in input().split()]
arr = [int(i) for i in input().split()]
y = defaultdict(int)
dp = [0] * n
for i in range(n - 1, -1, -1):
	if y[arr[i]] == 0:
		if i == n - 1:
			dp[i] = 1
		else:
			dp[i] = 1 + dp[i + 1]
	else:
		dp[i] = dp[i + 1]
	y[arr[i]] += 1
for _ in range(m):
	print(dp[int(input()) - 1])


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
c = [0] * 100001
p = [0] * n
o = 0
for i in range(n - 1, -1, -1):
	if c[l[i]] == 0:
		o += 1
		c[l[i]] = 1
		p[i] = o
	else:
		p[i] = o
for i in range(m):
	a = int(input())
	print(p[a - 1])


from collections import defaultdict
(sz, q) = [int(x) for x in input().strip().split()]
arr = [int(x) for x in input().strip().split()]
queries = []
for i in range(q):
	queries.append(int(input()))
m = [0 for x in range(sz)]
d = defaultdict(int)
uniques = 0
for i in range(sz - 1, -1, -1):
	e = arr[i]
	if e not in d:
		d[e] = 1
		uniques += 1
	m[i] = uniques
for i in range(q):
	print(m[queries[i] - 1])


class CodeforcesTask368BSolution:

	def __init__(self):
		self.result = ''
		self.n_m = []
		self.array = []
		self.ls = []

	def read_input(self):
		self.n_m = [int(x) for x in input().split(' ')]
		self.array = [int(x) for x in input().split(' ')]
		for _ in range(self.n_m[1]):
			self.ls.append(int(input()))

	def process_task(self):
		ss = set()
		dp = [0] * self.n_m[0]
		for x in range(self.n_m[0] - 1, -1, -1):
			ss.add(self.array[x])
			dp[x] = len(ss)
		res = []
		for q in self.ls:
			res.append(dp[q - 1])
		self.result = '\n'.join([str(x) for x in res])

	def get_result(self):
		return self.result
Solution = CodeforcesTask368BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


from sys import stdin, stdout
from collections import Counter
from itertools import permutations
import bisect
import math
I = lambda : map(int, stdin.readline().split())
I1 = lambda : stdin.readline()
(n, m1) = I()
a = list(I())
m = max(a)
c = [0] * (m + 1)
ans = [0] * n
cnt = 0
for i in range(n - 1, -1, -1):
	if c[a[i]] == 0:
		c[a[i]] = 1
		cnt += 1
	ans[i] = cnt
for i in range(m1):
	x = int(I1())
	print(ans[x - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = set()
F = [0] * n
for i in range(n - 1, -1, -1):
	b.add(a[i])
	F[i] = len(b)
for i in range(m):
	l = int(input())
	print(F[l - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
ans = [0] * m
d = {}
for i in range(n):
	d[a[i]] = i
ans2 = []
a = set(a)
for j in a:
	ans2.append(d[j])
ans2.sort()
ka = [0] * n
c = len(ans2)
for i in range(c):
	ka[ans2[i]] = c - i
i = 0
while i < n and ka[i] == 0:
	i += 1
for j in range(n - 2, -1, -1):
	if ka[j] == 0:
		ka[j] = ka[j + 1]
for i in range(m):
	b = int(input()) - 1
	ans[i] = ka[b]
for i in ans:
	print(i)


(n, m) = map(int, input().split())
a = input().split()
b = set()
for i in range(n):
	b.add(a[n - i - 1])
	a[n - i - 1] = len(b)
for _ in [0] * m:
	print(a[int(input()) - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))[::-1]
s = set()
r = [0] * n
k = 0
for i in range(n):
	if a[i] not in s:
		s.add(a[i])
		k += 1
		r[i] = k
	else:
		r[i] = k
r = r[::-1]
for i in range(m):
	print(r[int(input()) - 1])


tmp = [int(i) for i in input().split(' ')]
(n, m) = (tmp[0], tmp[1])
array1 = [int(i) for i in input().split(' ')]
array2 = []
for i in range(m):
	array2.append(int(input()))
array3 = []
dic = {}
t = 0
for i in range(n):
	if array1[-i - 1] not in dic:
		t += 1
		dic[array1[-i - 1]] = 1
	array3.append(t)
for i in array2:
	print(array3[-i])


from collections import Counter
(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
s = set()
b = [0 for i in range(n + 1)]
for i in range(n - 1, -1, -1):
	s.add(a[i])
	b[i + 1] = len(s)
for _ in range(m):
	l = int(input())
	print(b[l])


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
pas = []
t = {}
for i in l:
	if i not in t:
		t[i] = 1
	else:
		t[i] += 1
res = len(t.keys())
p = [res]
for i in range(n):
	el = l[i]
	t[el] -= 1
	if t[el] == 0:
		res -= 1
	p.append(res)
for i in range(m):
	print(p[int(input()) - 1])


import sys
(length, intervals) = map(int, sys.stdin.readline().split())
arr = list(map(int, sys.stdin.readline().split()))
ans = []
temp = set()
for x in range(length - 1, -1, -1):
	temp.add(arr[x])
	ans.append(len(temp))
ans.reverse()
for x in range(intervals):
	sys.stdout.write(str(ans[int(sys.stdin.readline()) - 1]) + '\n')


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
l = [int(input()) for _ in range(m)]
sujo = [False] * (10 ** 5 + 1)
for i in range(n - 1, -1, -1):
	if sujo[a[i]]:
		a[i] = None
	else:
		sujo[a[i]] = True
arr = [0] * (n + 1)
for i in range(n - 1, -1, -1):
	arr[i] = arr[i + 1] + (1 if a[i] != None else 0)
for e in l:
	print(arr[e - 1])


def string2list(x):
	x = x.split()
	i = 0
	for i in range(len(x)):
		x[i] = int(x[i])
	return x
para = string2list(input())
n = para[0]
m = para[1]
sequence = string2list(input())
tails = []
i = 0
mini = 0
maxi = n
while i < m:
	y = n - int(input())
	mini = min(mini, y)
	maxi = max(maxi, y)
	tails.append(y)
	i = i + 1
sequence.reverse()
i = 0
rep = 0
output = []
tree = {}
while i < maxi:
	x = sequence[i]
	flag = tree.get(sequence[i])
	if flag is None:
		tree.update({x: x})
		rep = rep + 1
	output.append(rep)
	i = i + 1
i = 0
while i < m:
	print(output[tails[i]])
	i = i + 1


3

def readln():
	return tuple(map(int, input().split()))
(n, m) = readln()
a = readln()
tmp = set()
cnt = [0] * n
for i in range(n - 1, -1, -1):
	tmp.add(a[i])
	cnt[i] = len(tmp)
ans = []
for _ in range(m):
	(l,) = readln()
	ans.append(str(cnt[l - 1]))
print('\n'.join(ans))


from sys import stdin
max_val = int(10000000000000.0)
min_val = int(-10000000000000.0)

def read_int():
	return int(stdin.readline())

def read_ints():
	return [int(x) for x in stdin.readline().split()]

def read_str():
	return input()

def read_strs():
	return [x for x in stdin.readline().split()]
(nb_elements, nb_query) = read_ints()
elements = read_ints()
counts = []
distinct = {}
while elements:
	distinct[elements.pop()] = 1
	counts += [len(distinct)]
for _ in range(nb_query):
	print(counts[nb_elements - read_int()])


(n, m) = map(int, input().split())
k = list(map(int, input().split()))
ans = [0] * n
kp = set()
for i in range(n, 0, -1):
	kp.add(k[i - 1])
	ans[i - 1] = len(kp)
for i in range(m):
	print(ans[int(input()) - 1])


(n, k) = map(int, input().split())
li = list(map(int, input().split()))
dic = {}
for _ in li:
	dic[_] = False
res = [0] * n
res[-1] = 1
dic[li[-1]] = True
for i in range(n - 2, -1, -1):
	if not dic[li[i]]:
		res[i] = res[i + 1] + 1
		dic[li[i]] = True
	else:
		res[i] = res[i + 1]
for i in range(k):
	print(res[int(input()) - 1])


(arraySize, times) = list(map(int, input().split()))
arrayNumbers = list(map(int, input().split()))
keysFound = {}
positions = {}
index = arraySize - 1
while index >= 0:
	newKeyFound = arrayNumbers[index]
	keysFound[newKeyFound] = 'found'
	positions[index] = len(keysFound)
	index -= 1
for time in range(times):
	position = int(input())
	print(positions[position - 1])


(n, m) = [int(x) for x in input().split()]
array = [0] + [int(x) for x in input().split()]
dp_distinct = [-1] * n + [1]
read_set = {array[-1]}
answers = []
for i in range(n - 1, 0, -1):
	if array[i] not in read_set:
		read_set.add(array[i])
		dp_distinct[i] = dp_distinct[i + 1] + 1
	else:
		dp_distinct[i] = dp_distinct[i + 1]
for fake_i in range(m):
	l = int(input())
	answers.append(dp_distinct[l])
print('\n'.join(map(str, answers)))


(flag, dp) = ([], [])

def process(n):
	for i in range(0, 100000 + 2, 1):
		flag.append(0)
		dp.append(0)
	dp[n + 1] = 0
	for i in range(n, 1 - 1, -1):
		dp[i] = dp[i + 1]
		if flag[a[i]] == 0:
			flag[a[i]] += 1
			dp[i] += 1

def dp002_sereja_and_suffixes(l):
	return dp[l]
(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
a.insert(0, 0)
process(n)
for i in range(m):
	l = int(input())
	print(dp[l])


from collections import *
(n, m) = map(int, input().split())
Arr = [int(_) for _ in input().split()]
Dic = Counter(Arr)
length = len(Dic.keys())
Hash = [0] * n
for i in range(n):
	a = Arr[i]
	Dic[a] -= 1
	Hash[i] = length
	if Dic[a] == 0:
		length -= 1
for j in range(m):
	k = int(input())
	print(Hash[k - 1])


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
d = {}
crack = [0]
arr.reverse()
for i in range(n):
	if arr[i] not in d.keys():
		d[arr[i]] = 1
		crack.append(crack[-1] + 1)
	else:
		crack.append(crack[-1])
crack.reverse()
for i in range(m):
	x = int(input())
	print(crack[x - 1])


(n, m) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
suffix = [0 for x in range(len(a))]
suffix[-1] = 1
sett = set()
sett.add(a[-1])
for i in range(len(a) - 2, -1, -1):
	suffix[i] = suffix[i + 1]
	if a[i] not in sett:
		suffix[i] += 1
		sett.add(a[i])
for _ in range(m):
	x = int(input())
	print(suffix[x - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
l = []
for _ in range(m):
	l.append(int(input()))
s = {a[n - 1]}
u = [1 for _ in range(n)]
for i in range(1, n):
	u[n - i - 1] = u[n - i] + (a[n - i - 1] not in s)
	s.add(a[n - i - 1])
for x in l:
	print(u[x - 1])


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
dp = [0] * n
dp[-1] = 1
cnt = [0] * int(100000.0 + 3)
cnt[arr[-1]] = 1
for i in range(len(arr) - 2, -1, -1):
	if cnt[arr[i]] == 0:
		dp[i] = dp[i + 1] + 1
	else:
		dp[i] = dp[i + 1]
	cnt[arr[i]] += 1
res = []
for i in range(m):
	x = int(input())
	res.append(str(dp[x - 1]))
print('\n'.join(res))


(len_list, len_nums) = list(map(int, input().split()))
sss = set()
index = []
for i in list(map(int, input().split()))[::-1]:
	sss.add(i)
	index.append(len(sss))
nums_list = []
for i in range(len_nums):
	nums_list.append(int(input()))
index.reverse()
for i in nums_list:
	print(index[i - 1])


m = input().split()
m = list(map(int, m))
s = input().split()
s = list(map(int, s))
l1 = []
for i in range(m[1]):
	l1.append(int(input()) - 1)
a = {'gh'}
l2 = []
for j in reversed(s):
	a.add(j)
	l2.append(len(a) - 1)
for k in l1:
	print(l2[m[0] - k - 1])


def main():
	(n, m) = map(int, input().split())
	aa = list(map(int, input().split()))
	cnt = [True] * (max(aa) + 1)
	(res, x) = ([], 0)
	for a in reversed(aa):
		if cnt[a]:
			cnt[a] = False
			x += 1
		res.append(x)
	print('\n'.join((str(res[n - int(input())]) for _ in range(m))))

def __starting_point():
	main()
__starting_point()


(n, t) = map(int, input().split())
k = list(map(int, input().split()))
w = [0] * n
r = set()
i = n - 1
while i >= 0:
	r.add(k[i])
	w[i] = len(r)
	i -= 1
for i in range(t):
	print(w[int(input()) - 1])


nm = list(map(int, input('').split(' ')))
nums = list(map(int, input('').split(' ')))
visited = [0] * (max(nums) + 2)
result = 0
result = [0]
for i in range(len(nums) - 1, -1, -1):
	count = 0
	if not visited[nums[i]]:
		count = 1
		visited[nums[i]] = 1
	result.append(result[-1] + count)
output = []
result.pop(0)
result = result[::-1]
for i in range(nm[1]):
	j = int(input(''))
	output.append(result[j - 1])
for i in output:
	print(i)


(n, m) = list(map(int, input().split()))
arr = list(map(int, input().split()))
l = []
a = [0] * n
for i in range(m):
	l.append(int(input()) - 1)
H = {}
unique = 0
for i in range(n - 1, -1, -1):
	if arr[i] not in H:
		H[arr[i]] = 1
		unique += 1
	a[i] = unique
for i in l:
	print(a[i])


from collections import Counter
(n, qnum) = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
ans = []
c = Counter(arr)
ml = len(c)
ans.append(ml)
for i in range(n - 1):
	if c[arr[i]] == 1:
		ml -= 1
		ans.append(ml)
	else:
		c[arr[i]] -= 1
		ans.append(ml)
for i in range(qnum):
	q = int(input()) - 1
	print(ans[q])


(n, m) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [0] * (n + 1)
s = set()
for i in range(n, 0, -1):
	s.add(a[i - 1])
	b[i] = str(len(s))
print('\n'.join([b[int(input())] for _ in range(m)]))


(n, m) = map(int, input().split())
array = list(map(int, input().split()))
distinct = set()
position = [0] * (n + 1)
for i in range(n - 1, -1, -1):
	pd = array[i] not in distinct
	distinct.add(array[i])
	position[i] = position[i + 1] + pd
for j in range(m):
	print(position[int(input()) - 1])


(arraySize, times) = list(map(int, input().split()))
arrayNumbers = list(map(int, input().split()))
keysFound = {}
positions = {}
index = arraySize - 1
while index >= 0:
	if not arrayNumbers[index] in keysFound:
		keysFound[arrayNumbers[index]] = 'found'
	positions[index] = len(keysFound)
	index -= 1
for time in range(times):
	print(positions[int(input()) - 1])


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
dp = set()
for i in range(n - 1, -1, -1):
	dp.add(l[i])
	l[i] = len(dp)
for _ in range(m):
	m = int(input())
	print(l[m - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
unique = set()
l = []
for i in range(m):
	l.append(int(input()))
l = list(enumerate(l))
l = sorted(l, key=lambda x: x[1], reverse=True)
final = []
for i in range(len(l)):
	if i == 0:
		unique.update(a[l[i][1] - 1:])
	else:
		unique.update(a[l[i][1] - 1:l[i - 1][1] - 1])
	final.append([len(unique), l[i][0]])
final = sorted(final, key=lambda x: x[1])
for i in final:
	print(i[0])


(n, m) = map(int, input().split())
lis = [int(x) for x in input().split()]
dic = {}
for i in range(n):
	if lis[i] not in dic:
		dic[lis[i]] = 1
	else:
		dic[lis[i]] += 1
ans = []
for i in range(n):
	l = len(dic)
	ans.append(l)
	if dic[lis[i]] == 1:
		dic.pop(lis[i])
	else:
		dic[lis[i]] -= 1
for i in range(m):
	x = int(input())
	print(ans[x - 1])


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
ls = [0] * n
s = set()
for i in range(n - 1, -1, -1):
	s.add(arr[i])
	ls[i] = len(s)
for k in range(m):
	print(ls[int(input()) - 1])


from collections import defaultdict
d = {}
d = defaultdict(int)
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
dp = [1] * n
d[l[-1]] = 1
for i in range(n - 2, -1, -1):
	if d[l[i]] == 0:
		d[l[i]] = 1
		dp[i] = dp[1 + i] + 1
	else:
		dp[i] = dp[i + 1]
s1 = ''
for _ in range(m):
	n1 = int(input())
	s1 += str(dp[n1 - 1]) + '\n'
print(s1)


import math
import sys
(n, m) = map(int, input().split())
d = list(map(int, input().split()))
MAXN = 10 ** 5 + 5
used = [0] * MAXN
suf = [0] * n
suf[n - 1] = 1
used[d[-1]] = 1
for i in range(n - 2, -1, -1):
	if used[d[i]] != 1:
		suf[i] = suf[i + 1] + 1
		used[d[i]] = 1
	else:
		suf[i] = suf[i + 1]
for i in range(m):
	t = int(input())
	print(suf[t - 1])


(n, m) = (int(s) for s in input().split())
arr = input().split()
size = n
arr2 = [0] * n
answ = [0] * m
known = {}
for i in range(m):
	answ[i] = int(input())
for i in range(len(arr) - 1, -1, -1):
	if arr[i] not in known:
		known[arr[i]] = 1
		arr2[size - i - 1] += 1
	if len(arr2) >= 2:
		arr2[size - i - 1] += arr2[size - i - 2]
for i in range(len(answ)):
	print(arr2[len(arr2) - answ[i]])


(n, m) = map(int, input().split())
s = list(map(int, input().split()))
ans = [0 for i in range(n + 1)]
dif = [False for i in range(10 ** 5 + 1)]
for i in range(n - 1, -1, -1):
	if not dif[s[i]]:
		ans[i] = ans[i + 1] + 1
		dif[s[i]] = True
	else:
		ans[i] = ans[i + 1]
print('\n'.join([str(ans[int(input()) - 1]) for _ in range(m)]))


def get_num_dist_for_positions(nums):
	dist = [0] * len(nums)
	dist_set = set()
	dist[len(nums) - 1] = 1
	dist_set.add(nums[-1])
	for index in range(len(nums) - 2, -1, -1):
		num = nums[index]
		if num in dist_set:
			dist[index] = dist[index + 1]
		else:
			dist[index] = dist[index + 1] + 1
			dist_set.add(num)
	return dist

def get_answers(nums, queries):
	dist = get_num_dist_for_positions(nums)
	return [dist[query - 1] for query in queries]

def solve():
	first_line = input()
	num_of_queries = int(first_line.split()[1])
	second_line = input()
	nums = [int(num) for num in second_line.split()]
	queries = []
	for _ in range(0, num_of_queries):
		query = int(input())
		queries.append(query)
	answers = get_answers(nums, queries)
	for answer in answers:
		print(answer)
solve()


(n, m) = map(int, input().split())
li = [int(k) for k in input().split()]
s = set()
s.add(li[n - 1])
dp = [1] * n
for i in range(n - 2, -1, -1):
	if li[i] in s:
		dp[i] = dp[i + 1]
	else:
		s.add(li[i])
		dp[i] = dp[i + 1] + 1
for j in range(m):
	l = int(input())
	print(dp[l - 1])


from os import environ
from sys import stdin, stdout
from math import gcd

class Input:

	def read(self, func):
		return func(stdin.readline().strip())

	def readn(self, func):
		return list(map(func, stdin.readline().strip().split()))

	def readiter(self):
		return iter(stdin.readline().strip().split())

	def next(self, it, func):
		return func(next(it))
pin = Input()
LOCAL = environ.get('LOCAL')

def local(func):

	def innerFunc(*args, **kwargs):
		if LOCAL:
			return func()
	return innerFunc

def testcases(func):

	def innerFunc(*args, **kwargs):
		T = pin.read(int)
		for tt in range(T):
			func(*args, **kwargs)
	return innerFunc

@local
def debug(*args):
	print(*args)

class Task:

	def solveOne(self):
		(n, m) = pin.readn(int)
		A = pin.readn(int)
		proprocessing = [0] * n
		mp = {}
		debug(*A)
		for i in range(n - 1, -1, -1):
			mp[A[i]] = True
			proprocessing[i] = len(mp)
		for i in range(m):
			x = pin.read(int)
			print(proprocessing[x - 1])
task = Task()
task.solveOne()


(n, m) = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
l = [0] * n
s = set()
arr.reverse()
for (i, e) in enumerate(arr):
	s.add(e)
	l[n - i - 1] = len(s)
for _ in range(m):
	x = int(input())
	print(l[x - 1])


(n, m) = map(int, input().split())
arr = [int(i) for i in input().split()]
answers = list()
unique = set()
for i in arr[::-1]:
	unique.add(i)
	answers.append(len(unique))
answers = answers[::-1]
for i in range(m):
	e = int(input())
	print(answers[e - 1])


[n, m] = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
l = []
dic = {}
for i in range(m):
	y = int(input())
	l.append(y)
	dic[y] = -1
k = sorted(l, reverse=True)
s = set([])
for i in k:
	if i <= n:
		for j in range(i - 1, n):
			try:
				dic[j] == -1
				if dic[j] != -1:
					break
				else:
					s.add(a[j])
			except:
				s.add(a[j])
		dic[i] = len(s)
for i in l:
	print(dic[i])


def solve(n, m, a, l):
	a = a[::-1]
	l = l[::-1]
	l = list(map(lambda x: n - x, l))
	ar = [False] * 100001
	lar = []
	c = 0
	out = ''
	for i in range(n):
		if ar[a[i]] == False:
			c += 1
			ar[a[i]] = True
		lar.append(c)
	for e in l[::-1]:
		out += str(lar[e]) + '\n'
	return out
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
l = []
for i in range(m):
	l.append(int(input()))
print(solve(n, m, a, l))


import math

class Input:

	def readInt(self):
		return int(input())

	def readIntArray(self):
		return [int(x) for x in input().split(' ')]

	def readString(self):
		return input()

	def readStringArray(self):
		return input().split(' ')

	def readFloat(self):
		return float(input())

	def readFloatArray(self):
		return [float(x) for x in input().split(' ')]

def main():
	inp = Input()
	(n, m) = inp.readIntArray()
	arr = inp.readIntArray()
	uniq = set()
	ans = []
	for i in reversed(range(n)):
		uniq.add(arr[i])
		ans.append(len(uniq))
	ans = ans[::-1]
	for _ in range(m):
		l = inp.readInt()
		print(ans[l - 1])
main()


import sys
input = sys.stdin.buffer.readline
(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
count = 0
s = set()
z = [0] * n
for i in range(n - 1, -1, -1):
	if arr[i] not in s:
		s.add(arr[i])
		count += 1
	z[i] = count
while m:
	m -= 1
	l = int(input())
	print(z[l - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
t = []
for i in range(m):
	t.append(int(input()))
d = set()
d.add(a[-1])
s = a.pop()
f = [1]
while a != []:
	d.add(a[-1])
	f.append(len(d))
	s = a.pop()
for j in t:
	print(f[n - j])


(n, m) = list(map(int, input().split()))
arr = list(map(int, input().split()))
s = set()
A = []
cnt = 0
for i in reversed(arr):
	if i not in s:
		cnt += 1
	A.append(cnt)
	s.add(i)
A = list(reversed(A))
for _ in range(m):
	t = int(input())
	print(A[t - 1])


(t1, t2) = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
p = set([l[-1]])
l[t1 - 1] = 1
for i in range(t1 - 2, -1, -1):
	if l[i] in p:
		l[i] = l[i + 1]
	else:
		p.add(l[i])
		l[i] = l[i + 1] + 1
for i in range(t2):
	q = int(input()) - 1
	print(l[q])


(n, m) = map(int, input().split())
a = input().split()
b = set()
for i in range(1, n + 1):
	b.add(a[-i])
	a[-i] = str(len(b))
print('\n'.join([a[int(input()) - 1] for i in range(m)]))


(ass, lss) = input().split()
Aarray = [int(x) for x in input().split()]
Larray = []
ans = {}
my_dict = {}
for x in range(int(lss)):
	Larray.append(int(input()))
for x in range(int(ass), -1, -1):
	if Aarray[x - 1] not in my_dict:
		my_dict[Aarray[x - 1]] = 0
	ans[x] = len(my_dict.keys())
for x in range(int(lss)):
	print(ans[Larray[x]])


(n, m) = map(int, input().split())
b = list(map(int, input().split()))
a = set()
unq = [0] * n
for i in range(n - 1, -1, -1):
	a.add(b[i])
	unq[i] = len(a)
l = []
for i in range(m):
	l.append(int(input()))
j = 0
for i in range(m):
	print(unq[l[i] - 1])


(n, m) = [int(n) for n in input().split()]
a = [int(a) for a in input().split()]
res = [0] * n
q = {a[n - 1]}
res[n - 1] = len(q)
for i in range(n - 2, -1, -1):
	q.add(a[i])
	res[i] = len(q)
for i in range(m):
	tmp = int(input())
	print(res[tmp - 1])


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
s = set()
req = [0] * n
for i in range(n - 1, -1, -1):
	s.add(arr[i])
	req[i] = len(s)
for i in range(m):
	print(req[int(input()) - 1])


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
ans = [0] * n
dic = {}
ans[-1] = 1
dic[l[-1]] = 1
for i in range(n - 2, -1, -1):
	if dic.get(l[i], 0) == 0:
		ans[i] = ans[i + 1] + 1
		dic[l[i]] = 1
	else:
		ans[i] = ans[i + 1]
for i in range(m):
	print(ans[int(input()) - 1])


(x, y) = map(int, input().split())
li = list(map(int, input().split()))
dp = [0] * (len(li) + 1)
li = li[::-1]
set1 = set()
for i in range(len(li)):
	dp[i] = dp[i - 1] + (li[i] not in set1)
	set1.add(li[i])
dp = dp[::-1]
for i in range(y):
	print(dp[int(input())])


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
new = set()
result = []
for i in range(n - 1, -1, -1):
	new.add(arr[i])
	result.append(len(new))
result.reverse()
for i in range(m):
	x = int(input()) - 1
	print(result[x])


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
aux = n * [0]
unique = set()
for i in range(n - 1, -1, -1):
	unique.add(arr[i])
	aux[i] = len(unique)
for i in range(m):
	index = int(input())
	print(aux[index - 1] - aux[n - 1] + 1)


cnt = lambda s, i: s.count(i)
ii = lambda : int(input())
si = lambda : input()
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
(n, m) = f()
l = il()
z = set()
for i in range(n - 1, -1, -1):
	z.add(l[i])
	l[i] = len(z)
print('\n'.join((str(l[ii() - 1]) for _ in range(m))))


(n, q) = map(int, input().split())
arr = list(map(int, input().split()))
brr = [0] * n
d = set()
for i in range(n - 1, -1, -1):
	if arr[i] not in d:
		d.add(arr[i])
	brr[i] = len(d)
for i in range(q):
	print(brr[int(input()) - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
l = []
for _ in range(m):
	l.append(int(input()))
last = dict()
for i in range(n):
	last[a[i]] = i
dp = [0] * n
dp[0] = len(set(a))
for i in range(n - 1):
	if last[a[i]] == i:
		dp[i + 1] = dp[i] - 1
	else:
		dp[i + 1] = dp[i]
res = []
for l_i in l:
	res.append(dp[l_i - 1])
print('\n'.join(map(str, res)))


import math as mt
import sys, string, bisect
input = sys.stdin.readline
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
(n, m) = M()
l = L()
d = defaultdict(int)
g = []
c = 0
for i in range(n - 1, -1, -1):
	if d[l[i]] == 0:
		c += 1
		g.append(c)
		d[l[i]] = 1
	else:
		g.append(c)
g.reverse()
for i in range(m):
	a = I()
	print(g[a - 1])


import sys
(n, m) = map(int, input().split())
list1 = list(map(int, input().split()))
l = [0] * n
c = 0
freq1 = set()
for i in range(n - 1, -1, -1):
	if list1[i] not in freq1:
		c += 1
		freq1.add(list1[i])
	l[i] = c
for _ in range(m):
	p = int(sys.stdin.readline())
	print(l[p - 1])


from sys import stdin, stdout
(n, m) = map(int, stdin.readline().split())
A = [0] + [int(x) for x in stdin.readline().split()]
AllInp = stdin.readlines()
Res = [-1] * (n + 1)
B = []
flag = [1] * 100001
for i in range(n, 0, -1):
	if flag[A[i]]:
		B.append(A[i])
		flag[A[i]] = 0
	Res[i] = len(B)
Ans = []
for Inp in AllInp:
	l = int(Inp)
	Ans.append(str(Res[l]))
stdout.write('\n'.join(Ans))


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
dp = a
Data = set()
for i in range(n - 1, -1, -1):
	Data.add(a[i])
	dp[i] = len(Data)
for i in range(m):
	print(dp[int(input()) - 1])


f = [0 for i in range(100001)]
(n, m) = map(int, input().split())
arr = list(map(int, input().strip().split()))
dis = [0 for i in range(n)]
dis[n - 1] = 1
f[arr[n - 1]] += 1
num = [int(input()) for i in range(m)]
for i in range(n - 2, -1, -1):
	if f[arr[i]] == 0:
		dis[i] += 1
	dis[i] += dis[i + 1]
	f[arr[i]] += 1
for i in range(m):
	num[i] = dis[num[i] - 1]
print('\n'.join(map(str, num)))


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
dp = [1] * n
s = set()
s.add(a[n - 1])
for i in range(n - 2, -1, -1):
	if a[i] in s:
		dp[i] = dp[i + 1]
	else:
		s.add(a[i])
		dp[i] = dp[i + 1] + 1
for _ in range(m):
	l = int(input())
	print(dp[l - 1])


R = lambda : map(int, input().split())
(n, m) = R()
a = list(R())
dp = [0] * n
v = set()
for i in range(n - 1, -1, -1):
	v.add(a[i])
	dp[i] = len(v)
for _ in range(m):
	x = int(input())
	print(dp[x - 1])


[n, m] = list(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))
t = [0] * n
check = [0] * 100001
t[n - 1] = 1
check[a[n - 1]] += 1
for i in range(0, n - 1):
	j = n - 2 - i
	check[a[j]] += 1
	t[j] = t[j + 1] + (1 if check[a[j]] == 1 else 0)
for i in range(0, m):
	j = int(input())
	print(t[j - 1])


import sys
input = sys.stdin.buffer.readline
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
visit = []
a.reverse()
d = {}
c = 0
for i in a:
	if i not in d:
		d[i] = 1
		c += 1
		visit.append(c)
	else:
		visit.append(c)
visit.reverse()
for i in range(m):
	l = int(input())
	print(visit[l - 1])


(n, m) = map(int, input().split())
l = [0] * (10 ** 5 + 10)
p = [0] * n
a = list(map(int, input().split()))
c = 0
for i in range(n - 1, -1, -1):
	if l[a[i]] == 0:
		c += 1
		l[a[i]] = 1
	p[i] = c
for i in range(m):
	x = int(input())
	print(p[x - 1])


def sol():
	(n, m) = map(int, input().split())
	A = [int(i) for i in input().split()]
	dp = [0] * n
	p = max(A)
	C = [0] * p
	for i in range(n):
		C[A[i] - 1] += 1
	B = []
	cnt = 0
	for i in range(n - 1, -1, -1):
		if C[A[i] - 1] != 0:
			B.append(A[i])
			cnt += 1
			C[A[i] - 1] = 0
		dp[i] = cnt
	q = len(B)
	for _ in range(m):
		l = int(input())
		print(dp[l - 1])
sol()


(n, m) = list(map(int, input().split(' ')))
x = list(map(int, input().split(' ')))
(index, a) = (dict(), set())
for i in range(n - 1, -1, -1):
	a.add(x[i])
	index[i + 1] = len(a)
for i in range(m):
	print(index[int(input())])


def single():
	return input()

def multiple():
	return list(map(int, input().split()))
(n, m) = multiple()
arr = multiple()
res = []
for i in range(m):
	res.append([int(input()), i])
res.sort()
d = dict()
l = 0
for i in arr:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
		l += 1
fun = [0] * m
x = 0
for i in res:
	(start, pos) = (i[0] - 1, i[1])
	while 1:
		if x < n and start > x:
			d[arr[x]] -= 1
			if d[arr[x]] == 0:
				l -= 1
			x += 1
		else:
			fun[pos] = l
			break
for i in fun:
	print(i)


import sys
(n, m) = map(int, input().split())
list = [int(x) for x in sys.stdin.readline().split()]
u = 0
SET = [0] * 100010
num = [0] * (n + 1)
for i in range(n - 1, -1, -1):
	if SET[list[i]] == 0:
		SET[list[i]] += 1
		u += 1
	num[i + 1] = u
for i in range(m):
	print(num[int(sys.stdin.readline())])


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
l.reverse()
dp = [0] * n
k = set()
temp = []
for i in range(n):
	k.add(l[i])
	temp.append(len(k))
temp.reverse()
for i in range(m):
	print(temp[int(input()) - 1])


(n, m) = map(int, input().split())
ls = list(map(int, input().split()))
mp = {}
for val in ls:
	if val in mp:
		mp[val] += 1
	else:
		mp[val] = 1
dp = []
for val in ls:
	if mp[val] > 1:
		mp[val] -= 1
		dp.append(len(mp))
	else:
		dp.append(len(mp))
		del mp[val]
i = int(0)
while i < m:
	q = int(input())
	print(dp[q - 1])
	i += 1


R = lambda : map(int, input().split())
(n, m) = R()
a = list(R())
c = []
t = {}
while a:
	t[a.pop()] = 1
	c += [len(t)]
for _ in range(m):
	print(c[n - int(input())])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
seen = set()
count = 0
count_dict = {}
for i in range(n - 1, -1, -1):
	if a[i] not in seen:
		seen.add(a[i])
		count += 1
	count_dict[i + 1] = count
for i in range(m):
	l = int(input())
	print(count_dict[l])


import sys
(n, m) = [int(x) for x in sys.stdin.readline().strip().split()]
arr = [int(x) for x in sys.stdin.readline().strip().split()]
d = {}
vals = [0] * n
pre = 10 ** 10
for i in range(0, m):
	l = int(sys.stdin.readline().strip())
	if vals[l - 1] != 0:
		print(vals[l - 1])
	else:
		unique = vals[min(n - 1, pre - 1)]
		for j in range(min(n - 1, pre - 2), l - 2, -1):
			if arr[j] not in d:
				d[arr[j]] = True
				unique += 1
				vals[j] = unique
			else:
				vals[j] = unique
		pre = l
		print(unique)


import sys
(n, num_of_queries) = [int(r) for r in input().split()]
numbers = [int(r) for r in input().split()]
distinct_nums = []
seen_nums = [False for x in range(100001)]
current_num_of_distinct_nums = 0
for num in numbers[::-1]:
	if not seen_nums[num]:
		seen_nums[num] = True
		current_num_of_distinct_nums += 1
	distinct_nums.append(current_num_of_distinct_nums)
queries = sys.stdin.readlines()
for query in queries:
	position = int(query) - 1
	print(distinct_nums[n - 1 - position])


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
seen = set()
for i in range(n - 1, -1, -1):
	seen.add(l[i])
	l[i] = str(len(seen))
print('\n'.join([l[int(input()) - 1] for _ in range(m)]))


while True:
	try:
		(n, m) = map(int, input().strip().split())
		list = [i for i in map(int, input().strip().split())]
		ai = []
		for i in range(m):
			ai.append(int(input()))
		tmp = set()
		res = []
		j = len(list) - 1
		while j >= 0:
			tmp.add(list[j])
			res.append(tmp.__len__())
			j -= 1
		for k in ai:
			print(res[-k])
	except:
		break


(n, m) = map(int, input().split())
array = input().split()
indexes = [int(input()) - 1 for _ in range(m)]
nums = set()
for i in range(n - 1, -1, -1):
	nums.add(array[i])
	array[i] = len(nums)
for i in indexes:
	print(array[i])


from collections import defaultdict
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
l = []
for _ in range(m):
	l.append(int(input()))
diff = {len(a): 0}
diff_dict = defaultdict(lambda : False)
for i in range(len(a) - 1, -1, -1):
	diff[i] = diff[i + 1]
	if not diff_dict[a[i]]:
		diff[i] += 1
		diff_dict[a[i]] = True
for i in l:
	print(diff[i - 1])


def solution(l_arr, t):
	arr = [int(x) for x in input().split()]
	dp = [0] * l_arr
	ss = {arr[-1]}
	dp[-1] = 1
	for i in range(l_arr - 2, -1, -1):
		v = arr[i]
		if v not in ss:
			dp[i] = dp[i + 1] + 1
			ss.add(v)
		else:
			dp[i] = dp[i + 1]
	r = [1] * t
	for i in range(t):
		p = int(input())
		r[i] = dp[p - 1]
	print('\n'.join(map(str, r)))

def main():
	(l_arr, t) = map(int, input().split())
	solution(l_arr, t)
main()


import sys, threading, os.path
import collections, heapq, math, bisect
import string
from platform import python_version
import itertools
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)

def main():
	if os.path.exists('input.txt'):
		input = open('input.txt', 'r')
	else:
		input = sys.stdin
	(n, m) = list(map(int, input.readline().split()))
	lis = list(map(int, input.readline().split()))
	lis3 = list(reversed(lis))
	set1 = set()
	lis2 = [0] * n
	j = n - 1
	for (i, x) in enumerate(lis3):
		if i == 0:
			lis2[j] = 1
			set1.add(x)
			j -= 1
			continue
		if x not in set1:
			lis2[j] = lis2[j + 1] + 1
		else:
			lis2[j] = lis2[j + 1]
		set1.add(x)
		j -= 1
	sol = []
	for i in range(m):
		temp = int(input.readline())
		sol.append(lis2[temp - 1])
	output = '\n'.join(map(str, sol))
	if os.path.exists('output.txt'):
		open('output.txt', 'w').writelines(str(output))
	else:
		sys.stdout.write(str(output))
main()


(n, m) = map(int, input().split())
ns = list(map(int, input().split()))
k = set()
for i in range(n - 1, -1, -1):
	k.add(ns[i])
	ns[i] = len(k)
for _ in '0' * m:
	print(ns[int(input()) - 1])


(n, m) = list(map(int, input().split()))
an = list(map(int, input().split()))
mxx = max(an)
saw = [False] * (mxx + 1)
dis = [0] * (n + 1)
for i in range(n - 1, -1, -1):
	x = an[i]
	dis[i] = dis[i + 1] if saw[x] else dis[i + 1] + 1
	saw[x] = True
[print(dis[int(input()) - 1]) for i in range(m)]


M = lambda : map(int, input().split())
L = lambda : list(map(int, input().split()))
I = lambda : int(input())
(n, k) = M()
t = reversed(L())
(p, r) = ([0] * (n + 2), [1] * 100001)
for (i, j) in enumerate(t, 1):
	(p[i], r[j]) = (p[i - 1] + r[j], 0)
p.reverse()
print('\n'.join(map(str, (p[I()] for i in range(k)))))


from collections import defaultdict
import sys

def solve():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = []
	res = defaultdict(int)
	for i in range(n):
		res[a[i]] += 1
	prev = len(list(res.values()))
	res[a[0]] -= 1
	ans = [0]
	ans.append(prev)
	for i in range(1, n):
		if res[a[i - 1]] == 0:
			prev -= 1
		res[a[i]] -= 1
		ans.append(prev)
	for i in range(m):
		temp = int(sys.stdin.readline())
		print(ans[temp])
solve()


(n, m) = map(int, input().split())
a = input().split()
b = set()
for i in range(n):
	b.add(a[n - i - 1])
	a[n - i - 1] = len(b)
for j in range(m):
	c = int(input())
	print(a[c - 1])


(n, m) = (int(i) for i in input().split())
l = [int(i) for i in input().split()]
l1 = [0] * n
s = set()
for i in range(n - 1, -1, -1):
	s.add(l[i])
	l1[i - n] = len(s)
l2 = []
for w in range(m):
	li = int(input())
	l2 += [str(l1[li - 1])]
print('\n'.join(l2))


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
met = [0] * (max(arr) + 1)
met[arr[-1]] = 1
dp = [1] * len(arr)
for i in range(len(arr) - 2, -1, -1):
	if met[arr[i]]:
		dp[i] = dp[i + 1]
	else:
		dp[i] = dp[i + 1] + 1
		met[arr[i]] = 1
for _ in range(m):
	print(dp[int(input()) - 1])


(n, m) = map(int, input().split())
a = [0] + list(map(int, input().split())) + [0]
fr = [0] * 2020202
dp = [0] * (n + 2)
for i in range(n, 0, -1):
	dp[i] = dp[i + 1] + 1 if fr[a[i]] == 0 else dp[i + 1]
	fr[a[i]] = 1
for _ in range(m):
	u = int(input())
	print(dp[u])


def main():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	dp = [0] * n
	dp[-1] = 1
	cnt = [0] * 100001
	cnt[a[-1]] = 1
	for i in range(len(a) - 2, -1, -1):
		if cnt[a[i]] == 0:
			dp[i] = dp[i + 1] + 1
		else:
			dp[i] = dp[i + 1]
		cnt[a[i]] += 1
	res = []
	for i in range(m):
		x = int(input())
		res.append(str(dp[x - 1]))
	print('\n'.join(res))
main()


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
t = []
s = set()
for i in range(n - 1, -1, -1):
	s.add(a[i])
	t.append(len(s))
t = t[::-1]
for i in range(m):
	l = int(input())
	print(t[l - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
s = set([])
p = [0] * n
for i in reversed(range(n)):
	if not a[i] in s:
		s.add(a[i])
	p[i] = len(s)
for i in range(m):
	l = int(input())
	print(p[l - 1])


from sys import *
from bisect import *
(n, m) = map(int, stdin.readline().split())
a = list(map(int, input().split()))
ll = []
for i in range(m):
	l = int(input())
	ll.append(l)
d = {a[-1]: 1}
dp = [1] * n
for i in range(n - 2, -1, -1):
	if a[i] not in d:
		d[a[i]] = 1
		dp[i] = dp[i + 1] + 1
	else:
		dp[i] = dp[i + 1]
for l in ll:
	print(dp[l - 1])


(n, m) = input().split()
n = int(n)
m = int(m)
l = list(input().split())
a = set({})
for i in range(n):
	a.add(l[n - i - 1])
	l[n - i - 1] = len(a)
for j in range(m):
	print(l[int(input()) - 1])


(n, m) = tuple(map(int, input().split()))
a = [int(i) for i in input().split()]
d = {}
g = [1 for i in range(n)]
d[a[n - 1]] = True
actual = 1
for i in range(n - 2, -1, -1):
	if not d.get(a[i]):
		actual += 1
		d[a[i]] = True
	g[i] = actual
while m:
	m -= 1
	i = int(input()) - 1
	print(g[i])


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
dp = [0] * (n + 1)
f = [0] * (10 ** 5 + 1)
for i in range(n - 1, -1, -1):
	if f[l[i]] == 0:
		dp[i] += dp[i + 1] + 1
		f[l[i]] = 1
	else:
		dp[i] += dp[i + 1]
for i in range(m):
	x = int(input())
	print(dp[x - 1])


import math as mt
import sys, string, bisect
input = sys.stdin.readline
import random
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
(n, m) = M()
d = [0] * (10 ** 5 + 1)
l = L()
i = n - 1
x = [0]
while i >= 0:
	if d[l[i]] == 0:
		d[l[i]] = 1
		x.append(x[-1] + 1)
	else:
		x.append(x[-1])
	i -= 1
w = x[-1::-1]
for i in range(m):
	q = I()
	print(w[q - 1])


num_input = input()
num_input = num_input.split(' ')
n = int(num_input[0])
m = int(num_input[1])
arr = input()
arr = arr.split(' ')
for i in range(0, len(arr)):
	arr[i] = int(arr[i])
m_arr = []
for i in range(0, m):
	temp = int(input())
	m_arr.append(temp)
arr_set = set()
dp = [0]
index = 1
for i in range(len(arr) - 1, -1, -1):
	if arr[i] in arr_set:
		dp.append(dp[index - 1])
	else:
		dp.append(dp[index - 1] + 1)
		arr_set.add(arr[i])
	index += 1
for i in range(0, len(m_arr)):
	print(dp[n - m_arr[i] + 1])


(n, m) = map(int, input().split())
dp = [0] * (n + 1)
l = list(map(int, input().split()))
s = set()
cnt = 0
for i in range(n - 1, -1, -1):
	if l[i] not in s:
		cnt = cnt + 1
		s.add(l[i])
	dp[i + 1] = cnt
for q in range(m):
	r = int(input())
	print(dp[r])


(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
dp = {n + 1: 0}
seen = set()
for (i, v) in enumerate(reversed(a)):
	i = n - i
	dp[i] = dp[i + 1]
	if v not in seen:
		seen.add(v)
		dp[i] += 1
for _ in range(m):
	i = int(input())
	print(dp[i])


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
abc = []
s = set()
for j in range(1, n + 1):
	s.add(x[-j])
	abc.append(len(s))
abc = abc[::-1]
ans = []
for i in range(m):
	ans.append(abc[int(input()) - 1])
print(*ans, sep='\n')


(n, m) = list(map(int, input().split()))
l = list(map(int, input().split()))
d = [0] * (100000 + 1)
a = dict()
ans = 0
for i in range(0, n):
	if d[l[n - 1 - i]] == 0:
		ans = ans + 1
		a[n - i] = ans
		d[l[n - 1 - i]] = 1
	else:
		a[n - i] = ans
for i in range(0, m):
	g = int(input())
	print(a[g])


(n, m) = map(int, input().split())
nums = list(map(int, input().split()))
flag = [0] * 100005
res = [0] * n
ans = 0
for i in range(n):
	if flag[nums[n - 1 - i]] == 0:
		ans += 1
		flag[nums[n - 1 - i]] += 1
	res[n - 1 - i] = ans
for i in range(m):
	left = int(input())
	print(res[left - 1])


(n, v) = (int(i) for i in input().split())
arr = [int(i) for i in input().split()]
nums = set()
arr_ = [0 for _ in range(n)]
for (i, val) in enumerate(reversed(arr)):
	if val not in nums:
		nums.add(val)
	arr_[n - 1 - i] = len(nums)
for _ in range(v):
	l = int(input())
	print(arr_[l - 1])


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
suf = [0 for _ in range(n)]
(s, ans) = (set(), [])
for i in range(n - 1, -1, -1):
	s.add(arr[i])
	suf[i] = len(s)
for i in range(m):
	l = int(input()) - 1
	ans.append(suf[l])
print(*ans, sep='\n')


(n, m) = map(int, input().split())
array = list(map(int, input().split()))[::-1]
array2 = set()
unicos = 0
for i in range(0, n):
	if not array[i] in array2:
		unicos += 1
		array2.add(array[i])
	array[i] = unicos
del array2
conclusion = ''
for i in range(0, m):
	conclusion += str(array[n - int(input())]) + '\n'
print(conclusion)


def read_int_array():
	return [int(x) for x in input().split(' ')]

def read_int():
	return int(input())

def main():
	(N, M) = read_int_array()
	arr = read_int_array()
	distinct_nos = set([])
	distinct_count = [0] * N
	for i in reversed(range(N)):
		distinct_nos.add(arr[i])
		distinct_count[i] = len(distinct_nos)
	for i in range(M):
		index = read_int() - 1
		print(distinct_count[index])
main()


(n, m) = map(int, input().split(' '))
array = input().split(' ')
listx = [int(input()) for inpt in range(m)]
nums = set()
for i in range(n - 1, -1, -1):
	nums.add(array[i])
	array[i] = len(nums)
for a in range(m):
	print(array[listx[a] - 1])


from functools import reduce
from collections import Counter
import time
import datetime
from math import sqrt, gcd

def time_t():
	print('Current date and time: ', datetime.datetime.now())
	print('Current year: ', datetime.date.today().strftime('%Y'))
	print('Month of year: ', datetime.date.today().strftime('%B'))
	print('Week number of the year: ', datetime.date.today().strftime('%W'))
	print('Weekday of the week: ', datetime.date.today().strftime('%w'))
	print('Day of year: ', datetime.date.today().strftime('%j'))
	print('Day of the month : ', datetime.date.today().strftime('%d'))
	print('Day of week: ', datetime.date.today().strftime('%A'))

def ip():
	return int(input())

def sip():
	return input()

def mip():
	return map(int, input().split())

def mips():
	return map(str, input().split())

def lip():
	return list(map(int, input().split()))

def matip(n, m):
	lst = []
	for i in range(n):
		arr = lip()
		lst.append(arr)
	return lst

def factors(n):
	return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def minJumps(arr, n):
	jumps = [0 for i in range(n)]
	if n == 0 or arr[0] == 0:
		return float('inf')
	jumps[0] = 0
	for i in range(1, n):
		jumps[i] = float('inf')
		for j in range(i):
			if i <= j + arr[j] and jumps[j] != float('inf'):
				jumps[i] = min(jumps[i], jumps[j] + 1)
				break
	return jumps[n - 1]

def dic(arr):
	return Counter(arr)

def prime(n):
	for i in range(3, int(n ** 0.5) + 1, 2):
		if n % i == 0:
			return False
	return True
import sys
(n, m) = map(int, sys.stdin.readline().split())
arr = list(map(int, sys.stdin.readline().split()))
lst = []
check = set()
k = 0
for i in range(n - 1, -1, -1):
	if arr[i] not in check:
		k += 1
		check.add(arr[i])
	lst.append(k)
while m:
	m -= 1
	k = int(sys.stdin.readline())
	print(lst[n - k])


(n, m) = input().split()
(n, m) = (int(n), int(m))
list = [int(i) for i in input().split()]
fr = [1] * n
d = {i: 0 for i in list}
d[list[-1]] = 1
for i in range(n - 2, -1, -1):
	if d[list[i]] == 0:
		fr[i] = fr[i + 1] + 1
	else:
		fr[i] = fr[i + 1]
	d[list[i]] = 1
while m:
	m -= 1
	i = int(input()) - 1
	print(fr[i])


(n, m) = map(int, input().split())
A = list(map(int, input().split()))
L = [int(input()) for _ in range(m)]
T = [0 for _ in range(n)]
T[n - 1] = 1
R = [0 for _ in range(10 ** 5 + 1)]
R[A[n - 1]] = 1
for i in range(n - 2, -1, -1):
	if R[A[i]]:
		T[i] = T[i + 1]
	else:
		T[i] = T[i + 1] + 1
		R[A[i]] = 1
for i in range(m):
	print(T[L[i] - 1])


(N, M) = map(int, input().split())
nList = input().split()
lastIdx = {nList[i]: i for i in range(N)}
count = len(lastIdx)
ansList = []
for n in range(N):
	ansList.append(count)
	if n == lastIdx[nList[n]]:
		count -= 1
for m in range(M):
	a = int(input())
	print(ansList[a - 1])


(n, m) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [0] * (n + 1)
s = set()
for i in range(n, 0, -1):
	s.add(a[i - 1])
	b[i] = str(len(s))
l = []
for i in range(m):
	l.append(int(input()))
print('\n'.join([b[t] for t in l]))


(n, m) = list(map(int, input().strip().split(' ')))
arr = list(map(int, input().strip().split(' ')))
res = [0 for i in range(n)]
ans = []
s = set()
for i in range(n - 1, -1, -1):
	s.add(arr[i])
	res[i] = len(s)
for _ in range(m):
	t = int(input())
	ans.append(res[t - 1])
for i in ans:
	print(i)


(n, m) = map(int, input().split())
ls = list(map(int, input().split()))
dp = [1 for i in range(n)]
unq = set()
unq.add(ls[-1])
for i in range(n - 2, -1, -1):
	if ls[i] not in unq:
		dp[i] = 1 + dp[i + 1]
		unq.add(ls[i])
	else:
		dp[i] = dp[i + 1]
for _ in range(m):
	x = int(input())
	print(dp[x - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = [0] * (n + 1)
usados = {}
for i in range(n - 1, -1, -1):
	if not usados.get(a[i], False):
		usados.update({a[i]: True})
		b[i] = 1
for i in range(n - 1, -1, -1):
	b[i] += b[i + 1]
k = []
for i in range(m):
	k.append(str(b[int(input()) - 1]))
print('\n'.join(k))


from sys import *
(o, m) = [int(x) for x in stdin.readline().rstrip().split()]
n = [int(x) for x in stdin.readline().rstrip().split()]
num = set()
num1 = 0
count = []
for i in reversed(range(len(n))):
	n1 = n[i]
	if n1 not in num:
		num1 += 1
		num.add(n1)
	count.append(num1)
count.reverse()
z = [int(x) - 1 for x in stdin.read().rstrip().split()]
result = [count[x] for x in z]
stdout.write('\n'.join([str(x) for x in result]))


def main():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	c = [0] * n
	c[n - 1] = 1
	s = [False] * 100001
	s[a[n - 1]] = True
	for i in range(1, n):
		if s[a[n - i - 1]]:
			c[n - i - 1] = c[n - i]
		else:
			c[n - i - 1] = c[n - i] + 1
			s[a[n - i - 1]] = True
	print('\n'.join((str(c[int(input()) - 1]) for _ in range(m))))
main()


(n, m) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
ans = set()
for i in range(1, n + 1):
	ans.add(a[-i])
	a[-i] = len(ans)
for i in range(m):
	print(a[int(input()) - 1])


(n, m) = [int(x) for x in input().strip().split()]
a = [int(x) for x in input().strip().split()]
used = set([a[-1]])
cnt = [1] * (n + 1)
for i in range(n - 2, -1, -1):
	if a[i] in used:
		cnt[i + 1] = cnt[i + 2]
	else:
		cnt[i + 1] = cnt[i + 2] + 1
		used.add(a[i])
for i in range(m):
	temp = int(input().strip())
	print(cnt[temp])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
v = [0] * 100001
ans = [0] * (n + 1)
ans[n] = 0
for i in range(n - 1, -1, -1):
	x = a[i]
	if v[x]:
		ans[i] = ans[i + 1]
	else:
		ans[i] = ans[i + 1] + 1
		v[x] = 1
for i in range(m):
	print(ans[int(input()) - 1])


from sys import stdin
a = list(map(int, stdin.readline().split()))
s = list(map(int, stdin.readline().split()))
s.insert(0, 'o')
haspmap = set()
count = 1
for i in range(a[0], 0, -1):
	if s[i] in haspmap:
		s[i] = s[i + 1]
	else:
		haspmap.add(s[i])
		s[i] = count
		count += 1
for i in range(0, a[1]):
	sd = int(input())
	print(s[sd])


(tamArray, quantInteiros) = input().split()
quantInteiros = int(quantInteiros)
tamArray = int(tamArray)
array = [*map(int, input().split())]
distintosIndice = []
conjunto = set()
for i in range(tamArray - 1, -1, -1):
	conjunto.add(array[i])
	tamanho = len(conjunto)
	distintosIndice.append(tamanho)
distintosIndice.reverse()
for i in range(quantInteiros):
	index = int(input()) - 1
	print(distintosIndice[index])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = []
r = []
h = [None] * 10 ** 6
for i in range(m):
	l = int(input())
	b.append(l)
c = 0
for i in range(n - 1, -1, -1):
	if h[a[i]] == None:
		c = c + 1
		h[a[i]] = 1
	r.append(c)
for i in range(m):
	print(r[n - b[i]])


(n, m) = input().split()
(n, m) = (int(n), int(m))
a = input().split()
a = [int(i) for i in a]
s = {}
l = [0] * n
for i in range(int(n)):
	s[a[i]] = 0
l[n - 1] = 1
s[a[n - 1]] = 1
for i in range(n - 2, -1, -1):
	l[i] = l[i + 1]
	if s[a[i]] == 0:
		l[i] += 1
		s[a[i]] = 1
for i in range(m):
	x = int(input())
	print(l[x - 1])


(n, m) = map(int, input().split())
a_vec = list(map(int, input().split()))
l_vec = []
for i in range(m):
	l_vec.append(int(input()))
dp_vec = [0] * n
dp_set = set()
for i in range(n - 1, -1, -1):
	dp_set.add(a_vec[i])
	dp_vec[i] = len(dp_set)
for i in range(m):
	print(dp_vec[l_vec[i] - 1])


a = set()
l = []
(n, m) = list(map(int, input().split(' ')))
for i in reversed(list(map(int, input().split(' ')))):
	a.add(i)
	l.append(len(a))
l.reverse()
for _ in range(m):
	print(l[int(input()) - 1])


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
d = {}
for i in range(n - 1, -1, -1):
	if l[i] in d:
		l[i] = 0
	else:
		d[l[i]] = 0
		l[i] = 1
for i in range(1, n):
	l[i] += l[i - 1]
l.insert(0, 0)
for _ in range(m):
	i = int(input())
	print(l[-1] - l[i - 1])


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
s = [0] * 100002
l1 = [0] * 100002
c = 0
for i in range(n):
	if s[l[n - i - 1]] == 0:
		s[l[n - i - 1]] = 1
		c += 1
	l1[n - i] = c
for i in range(m):
	a = int(input())
	print(l1[a])


(n, m) = map(int, input().split())
a = input().split()
l = []
s = set()
res = [0] * n
for i in range(m):
	l.append(int(input()) - 1)
for i in range(n - 1, -1, -1):
	s.add(a[i])
	res[i] = len(s)
for i in range(m):
	print(res[l[i]])


(n, m) = map(int, input().split())
l = [int(j) for j in input().split()]
d = [0] * (10 ** 5 + 1)
t = [0] * (10 ** 5 + 1)
k = 0
for i in range(n - 1, -1, -1):
	g = l[i]
	if d[g] == 0:
		k += 1
		d[g] += 1
	t[i] = k
for i in range(m):
	print(t[int(input()) - 1])


import collections
from sys import stdin

def s_s(A, L):
	dp = [0] * len(A)
	counter = collections.Counter()
	for i in range(len(A) - 1, -1, -1):
		counter[A[i]] += 1
		dp[i] = len(counter)
	for l in L:
		print(dp[l - 1])
line = stdin.readline()
(n, m) = (int(line.split(' ')[0]), int(line.split(' ')[1]))
line = stdin.readline()
A = [int(a) for a in line.split(' ')]
L = [int(stdin.readline()) for _ in range(m)]
s_s(A, L)


import sys
input = sys.stdin.readline
(x, y) = list(map(int, input().split()))
z = list(map(int, input().split()))
ans = [0 for i in range(10 ** 5 + 1)]
count = 0
dp = []
for i in range(len(z)):
	if ans[z[i]] == 0:
		count = count + 1
	ans[z[i]] += 1
for i in range(len(z)):
	if ans[z[i]] == 1:
		dp.append(count)
		count = count - 1
	else:
		ans[z[i]] = ans[z[i]] - 1
		dp.append(count)
for i in range(y):
	n = int(input())
	print(dp[n - 1])


(n, m) = map(int, input().split())
a = [int(x) for x in input().split()]
a = [0] + a
dic = {}
ind = []
b = set()
for i in range(n, 0, -1):
	b.add(a[i])
	dic.update({i: len(b)})
for i in range(m):
	ind.append(int(input()))
for i in ind:
	print(dic[i])


(n, m) = map(int, input().strip().split())
arr = list(map(int, input().strip().split()))
que = []
for i in range(m):
	que.append(int(input()))
sol = [0] * n
dic = {}
for i in range(n - 1, -1, -1):
	if arr[i] not in dic:
		dic[arr[i]] = 1
		if i == n - 1:
			sol[i] = 1
		else:
			sol[i] = sol[i + 1] + 1
	else:
		sol[i] = sol[i + 1]
for i in range(m):
	print(sol[que[i] - 1])


def fun():
	s = set()
	p = input().split()
	n = int(p[0])
	q = int(p[1])
	arr = input().split(' ')
	cnt = [0] * n
	for i in range(n - 1, -1, -1):
		s.add(int(arr[i]))
		cnt[i] = len(s)
	for i in range(int(q)):
		k = int(input())
		print(cnt[k - 1])
fun()


from collections import Counter
f = lambda : map(int, input().split())
(n, m) = f()
a = list(f())
s = set()
b = [0] * n
b[-1] = 1
s.add(a[-1])
for i in range(n - 2, -1, -1):
	b[i] = b[i + 1]
	if a[i] not in s:
		b[i] += 1
		s.add(a[i])
print('\n'.join([str(b[int(input()) - 1]) for _ in range(m)]))


(n, m) = map(int, input().split())
ai = list(map(int, input().split()))
li = [int(input()) for i in range(m)]
nums = [0] * n
ar = [0] * (10 ** 5 + 1)
num = 0
for i in range(n - 1, -1, -1):
	if ar[ai[i]] != 1:
		num += 1
	ar[ai[i]] = 1
	nums[i] = num
for i in range(m):
	print(nums[li[i] - 1])


(n, i) = map(int, input().split())
L = input().split()
a = set()
for k in range(1, n + 1):
	a.add(L[-k])
	L[-k] = str(len(a))
res = ''
print('\n'.join([L[int(input()) - 1] for k in range(i)]))


from math import ceil, sqrt, floor
(n, m) = map(int, input().split())
num = list(map(int, input().split()))
dp = [0] * (n + 1)
vu = [False] * (10 ** 5 + 5)
for i in range(n - 1, -1, -1):
	dp[i] = dp[i + 1]
	if not vu[num[i]]:
		vu[num[i]] = True
		dp[i] += 1
rep = []
for i in range(m):
	a = int(input())
	rep.append(str(dp[a - 1]))
print('\n'.join(rep))


def main(stdin):
	(n, m) = next(stdin).split()
	(n, m) = (int(n), int(m))
	a_i = next(stdin).split()
	checked = {}
	diff = {}
	checked[int(a_i[-1])] = 1
	diff[n - 1] = 1
	for i in range(n - 2, -1, -1):
		diff[i] = diff[i + 1]
		if int(a_i[i]) not in checked:
			diff[i] += 1
			checked[int(a_i[i])] = 1
	for l in stdin:
		print(diff[int(l) - 1])
import sys
main(sys.stdin)


(n, m) = list(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))
nums = set()
for i in range(n - 1, -1, -1):
	nums.add(a[i])
	a[i] = len(nums)
while m:
	print(a[int(input()) - 1])
	m -= 1


import sys
input = lambda : sys.stdin.readline()
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
f = set()
dp = []
for i in range(n - 1, -1, -1):
	f.add(l[i])
	dp.append(len(f))
dp.reverse()
for i in range(m):
	x = int(input())
	print(dp[x - 1])


from collections import Counter
in1 = input()
(n, m) = in1.split(' ')
m = int(m)
n = int(n)
line2 = input()
lst = list(map(int, line2.split(' ')))
idx = []
for i in range(m):
	idx.append(int(input()))
dst = Counter()
ans = []
for i in range(n, 0, -1):
	dst[lst[i - 1]] += 1
	ans.append(len(dst))
for i in idx:
	print(ans[n - i])


from collections import Counter
from sys import stdin, stdout
(n, m) = map(int, stdin.readline().split())
arr = list(map(int, stdin.readline().split()))
nums = Counter()
suff = Counter()
for i in range(n - 1, -1, -1):
	if i == n - 1:
		nums[arr[i]] = 1
		suff[i] += 1
	elif nums[arr[i]] == 0:
		suff[i] = suff[i + 1] + 1
		nums[arr[i]] = 1
	else:
		suff[i] = suff[i + 1]
for _ in range(m):
	l = int(stdin.readline())
	stdout.write(str(suff[l - 1]) + '\n')


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
q = [0] * 100001
w = []
k = 0
for i in range(n - 1, -1, -1):
	if q[a[i]] != 1:
		q[a[i]] = 1
		k += 1
	w.append(k)
for i in range(m):
	print(w[n - int(input())])


x1 = str(input()).split()
strr2 = list(map(int, str(input()).split()))
arr = [0] * int(x1[0])
s = set([strr2[-1]])
for i in range(1, int(x1[0]) + 1):
	s.add(strr2[-i])
	arr[-i] = len(s)
for i in range(int(x1[1])):
	print(arr[int(input()) - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = [0] * n
dic = [0] * 100001
cnt = 0
for i in range(n - 1, -1, -1):
	if dic[a[i]] == 0:
		dic[a[i]] = 1
		cnt += 1
		b[i] = cnt
	else:
		b[i] = cnt
for h in range(m):
	l = int(input())
	print(b[l - 1])


from bisect import bisect_left as bl
(n, m) = map(int, input().split())
(a, q) = (list(map(int, input().split())), {})
for i in range(n):
	q[a[i]] = i + 1
q = sorted(q.values())
w = len(q)
for i in range(m):
	print(w - bl(q, int(input())))


(n, m) = map(int, input().split())
a = [int(x) for x in input().split()]
a.insert(0, 0)
ans = [1]
check_table = [0] * (10 ** 5 + 1)
check_table[a[n]] = 1
for i in range(n - 1):
	if check_table[a[n - i - 1]]:
		ans.append(ans[-1])
	else:
		check_table[a[n - i - 1]] = 1
		ans.append(ans[-1] + 1)
ans.reverse()
for i in range(m):
	print(ans[int(input()) - 1])


import sys

def input():
	return sys.stdin.readline()[:-1]
(n, m) = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
l = [0] * n
s = set()
arr.reverse()
for (i, e) in enumerate(arr):
	s.add(e)
	l[n - i - 1] = len(s)
for _ in range(m):
	x = int(input())
	print(l[x - 1])


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
d = {}
b = set()
for i in range(n):
	b.add(arr[n - i - 1])
	d[n - i] = d.get(n - i, len(b))
for _ in range(m):
	x = int(input())
	print(d[x])


MX = 100008
[n, m] = list(map(int, input().split()))
arr = list(map(int, input().split()))
test = []
for i in range(m):
	test.append(int(input('')))
dp = [0] * MX
cnt = [0] * MX
flag = [0] * MX
for j in range(n - 1, -1, -1):
	if flag[arr[j]] == 0:
		dp[j] = dp[j + 1] + 1
		flag[arr[j]] = 1
	else:
		dp[j] = dp[j + 1]
for j in test:
	print(dp[j - 1])


def main():
	from sys import stdin, stdout, stderr
	(n, m) = map(int, stdin.readline().split())
	arr = [int(x) for x in stdin.readline().split()]
	queries = map(int, stdin)
	distincts = set()
	suff = []
	for i in reversed(arr):
		distincts.add(i)
		suff.append(len(distincts))
	ans = (str(suff[n - q]) for q in queries)
	stdout.write('\n'.join(ans) + '\n')
main()


(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
max_a = max(a)
visited = [0] * (max_a + 1)
distinct_nums_count = [0] * (n + 1)
distinct_nums_count[n] = 1
visited[a[n - 1]] = 1
for i in range(n - 2, -1, -1):
	if visited[a[i]] == 1:
		distinct_nums_count[i + 1] = distinct_nums_count[i + 2]
	else:
		distinct_nums_count[i + 1] = distinct_nums_count[i + 2] + 1
		visited[a[i]] = 1
for i in range(m):
	print(distinct_nums_count[int(input())])


from collections import Counter
(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
d = Counter(a)
b = []
s = set(a)
s = list(s)
b.append(len(s))
d[a[0]] -= 1
for i in range(1, len(a)):
	if d[a[i - 1]] > 0:
		b.append(b[i - 1])
		d[a[i]] -= 1
	else:
		b.append(b[i - 1] - 1)
		d[a[i]] -= 1
for i in range(m):
	x = int(input()) - 1
	print(b[x])


ans = []
(n, m) = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
E = [0] * (n + 1)
s = set()
a = 0
for x in range(n - 1, -1, -1):
	if l[x] not in s:
		a += 1
		s.add(l[x])
	E[x + 1] = a
for x in range(m):
	ans.append(E[int(input())])
for x in ans:
	print(x)


(n, m) = [int(i) for i in input().split(' ')]
a = [int(i) for i in input().split(' ')]
l = []
for i in range(m):
	l.append(int(input()))
ans = []
s = [False] * 100001
cnt = 0
for i in range(n - 1, -1, -1):
	if not s[a[i]]:
		s[a[i]] = True
		cnt += 1
	ans.append(cnt)
ans.reverse()
for i in range(m):
	print(ans[l[i] - 1])


(N, M) = map(int, input().split())
nList = input().split()
lastIdx = {nList[i]: i for i in range(N)}
lastIdxList = list(lastIdx.values())
lastIdxList.sort()
count = len(lastIdx)
ansList = []
ansIdx = 0
for c in range(count):
	l = lastIdxList[c] + 1
	ansList[ansIdx:l] = [count] * (l - ansIdx)
	ansIdx = l
	count -= 1
res = []
for m in range(M):
	a = int(input())
	res.append(ansList[a - 1])
[print(i) for i in res]


(N, M) = [int(i) for i in input().split(' ')]
arr = [int(i) for i in input().split(' ')]
p = set()
dp = [0] * N
for i in range(N - 1, -1, -1):
	p.add(arr[i])
	dp[i] = len(p)
for i in range(M):
	print(dp[int(input()) - 1])


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
s = set()
d = {}
for i in range(n)[::-1]:
	s.add(arr[i])
	d[i + 1] = len(s)
for _ in range(m):
	l = int(input())
	print(d[l])


(n, m) = map(int, input().split())
A = [int(i) for i in input().split()]
count = 0
B = [0] * (n - 1)
B.append(1)
dict = {A[n - 1]: 1}
for i in reversed(range(n - 1)):
	if A[i] not in dict:
		B[i] = B[i + 1] + 1
		dict[A[i]] = 1
	else:
		B[i] = B[i + 1]
		dict[A[i]] += 1
Ans = ''
for i in range(m):
	l = int(input())
	Ans += str(B[l - 1]) + '\n'
print(Ans)


import math
import sys
(n, m) = map(int, input().split())
d = list(map(int, input().split()))
used = set()
suf = [0] * n
suf[n - 1] = 1
used.add(d[-1])
for i in range(n - 2, -1, -1):
	if d[i] not in used:
		suf[i] = suf[i + 1] + 1
		used.add(d[i])
	else:
		suf[i] = suf[i + 1]
for i in range(m):
	t = int(input())
	print(suf[t - 1])


li = list(map(int, input().split()))
n = li[0]
m = li[1]
num = list(map(int, input().split()))
day = []
for j in range(m):
	day.append(int(input()))
numBucket = [0] * 100000
output = list()
difGirNum = 0
for i in range(n):
	if numBucket[num[n - 1 - i] - 1] == 0:
		difGirNum += 1
		numBucket[num[n - 1 - i] - 1] = 1
	output.append(difGirNum)
for item in day:
	print(output[n - item])


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
stat = [0 for i in range(n)]
d = dict(zip(l, stat))
memo = [0 for i in range(n + 1)]
d[l[n - 1]] = 1
memo[n] = 1
for j in range(n - 1, -1, -1):
	if d[l[j - 1]] == 0:
		check = 1
		d[l[j - 1]] = 1
	else:
		check = 0
	memo[j] = memo[j + 1] + check
for i in range(m):
	index = int(input())
	print(memo[index])


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
aux = set()
dp = [0] * n
for i in range(n - 1, -1, -1):
	aux.add(arr[i])
	dp[i] = len(aux)
for i in range(m):
	j = int(input()) - 1
	print(dp[j])


(n, m) = map(int, input().split())
a = [int(i) for i in input().split()]
dp = [None for _ in range(n)]
set_ = set()
for i in range(n - 1, -1, -1):
	set_.add(a[i])
	dp[i] = len(set_)
for _ in range(m):
	l = int(input())
	print(dp[l - 1])


import sys
input = lambda : sys.stdin.readline()
(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
mark = [0] * 100001
ans = [0] * 100001
for i in range(n - 1, -1, -1):
	ans[i] = ans[i + 1] + 1 - mark[a[i]]
	mark[a[i]] = 1
for i in range(m):
	print(ans[int(input()) - 1])


(n, m) = map(int, input().split())
numbers = list(map(int, input().split()))
secondNumbers = []
for i in range(0, m, 1):
	x = int(input())
	secondNumbers.append(x)
mysets = set()
answer = [0] * n
count = 0
for j in range(n - 1, -1, -1):
	mysets.add(numbers[j])
	length = len(mysets)
	if count < length:
		answer[j] = length
		count += 1
	else:
		answer[j] = length
for k in range(0, m, 1):
	print(answer[secondNumbers[k] - 1])


(n, m) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
distinct = set()
distinct_count = [0] * n
for i in range(n - 1, -1, -1):
	distinct.add(a[i])
	distinct_count[i] = len(distinct)
for _ in range(m):
	print(distinct_count[int(input()) - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
L = [0] * m
for i in range(m):
	x = int(input())
	L[i] = [x - 1, i]
L.sort(reverse=True)
ans = [0] * m
ind = n - 1
s = {}
for item in L:
	pos = item[0]
	x = item[1]
	while ind >= pos and ind >= 0:
		s[a[ind]] = 1
		ind -= 1
	ans[x] = len(s)
s = ''
for i in range(m):
	s += str(ans[i]) + '\n'
print(s, end='')


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
checked = set()
ans = [0] * n
for i in range(n - 1, -1, -1):
	checked.add(a[i])
	ans[i] = len(checked)
for _ in range(m):
	l = int(input())
	print(ans[l - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
s = set()
l1 = [0 for i in range(0, n)]
count = 0
for i in range(n - 1, -1, -1):
	if a[i] in s:
		l1[i] = count
	else:
		count += 1
		l1[i] = count
		s.add(a[i])
for i in range(0, m):
	temp = int(input())
	print(l1[temp - 1])


(n, m) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = []
for i in range(100001):
	b.append(0)
count = 0
for i in range(n):
	if b[a[i]] == 0:
		count += 1
	b[a[i]] += 1
l = []
for i in range(m):
	x = int(input())
	l.append(x)
dp = [0, count]
for i in range(2, n + 1):
	b[a[i - 2]] += -1
	if b[a[i - 2]] == 0:
		dp.append(dp[i - 1] - 1)
	else:
		dp.append(dp[i - 1])
for i in range(m):
	print(dp[l[i]])


import sys
import bisect
from collections import Counter, defaultdict as dd

def data():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var))

def l():
	return list(sp())

def strl():
	return list(strsp())

def sp():
	return map(int, data().split())

def strsp():
	return map(str, data().split())
(n, m) = sp()
a = l()
l = []
for i in range(m):
	l.append(int(data()))
dp = [0] * (n + 1)
dp[0] = len(set(a))
g = dd(lambda : 0)
for i in range(n):
	g[a[i]] += 1
g[a[0]] -= 1
for i in range(1, n):
	if g[a[i - 1]] > 0:
		dp[i] += dp[i - 1]
		g[a[i]] -= 1
	elif g[a[i - 1]] == 0:
		dp[i] += dp[i - 1] - 1
		g[a[i]] -= 1
for i in range(m):
	print(dp[l[i] - 1])


from sys import stdin, stdout
lines = stdin.readlines()
n = int(lines[0].split()[0])
m = int(lines[0].split()[1])
a = [int(x) for x in lines[1].split()]
l = [int(x) for x in lines[2:]]
set_a = []
hset = set()
for elem in reversed(a):
	hset.add(elem)
	set_a.append(len(hset))
answers = []
for elem in l:
	pos = n - elem
	answers.append(set_a[pos])
stdout.write('\n'.join([str(x) for x in answers]))


(n, m) = map(int, input().split())
a = [int(x) for x in input().split()]
memo = [0] * 100005
cont = [0] * (n + 1)
soma = 0
for i in range(n - 1, -1, -1):
	if memo[a[i]] == 0:
		soma += 1
	cont[i] = soma
	memo[a[i]] += 1
for mm in range(m):
	s = int(input())
	print(cont[s - 1])


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
l = []
for i in range(m):
	l.append(int(input()))
mxn = 10 ** 5 + 10
dp = [0] * mxn
seen = {}
count = 0
for i in range(n - 1, -1, -1):
	try:
		k = seen[arr[i]]
		dp[i] = count
	except:
		count += 1
		dp[i] = count
		seen[arr[i]] = i
for i in l:
	print(dp[i - 1])


(n, m) = map(int, input().split())
num = input().split()
for i in range(n):
	num[i] = int(num[i])
sets = set()
res = [int(0) for i in range(n)]
for i in range(n - 1, -1, -1):
	sets.add(num[i])
	res[i] = len(sets)
num2 = []
for i in range(m):
	print(res[int(input()) - 1])


def finding_unique(seq, n):
	check = [0] * 100005
	length = [0] * n
	for y in range(n - 1, -1, -1):
		if y == n - 1:
			length[y] = 1
			check[seq[y]] = 1
		elif check[seq[y]] == 1:
			length[y] = length[y + 1]
		else:
			length[y] = length[y + 1] + 1
			check[seq[y]] = 1
	return length
(n, m) = list(map(int, input().split()))
seq = list(map(int, input().split()))
ans = finding_unique(seq, n)
for x in range(m):
	i = int(input())
	print(ans[i - 1])


import sys
input = sys.stdin.readline

def gint():
	return int(input())

def gint_arr():
	return list(map(int, input().split()))

def gfloat():
	return float(input())

def gfloat_arr():
	return list(map(float, input().split()))

def pair_int():
	return map(int, input().split())
INF = 1 << 31
dx = [-1, 0, 1, 0]
dy = [0, 1, 0, -1]
(n, m) = gint_arr()
a = gint_arr()
s = [0] * n
s[0] = 1
unique = [False] * (100000 + 1)
unique[a[n - 1]] = True
i = n - 2
while ~i:
	s[n - i - 1] = s[n - i - 2] + (not unique[a[i]])
	unique[a[i]] = True
	i -= 1
while m:
	i = gint()
	print(s[n - i])
	m -= 1


(n, m) = map(int, input().split())
(girls, judge, ans, sum) = (list(map(int, input().split())), [False] * 100001, [0] * n, 0)
for i in range(n):
	judge[girls[i]] = True
for i in range(n):
	if judge[girls[n - 1 - i]]:
		sum += 1
		judge[girls[n - 1 - i]] = False
	ans[n - 1 - i] = sum
for i in range(m):
	ai = int(input())
	print(ans[ai - 1])


import math
import itertools
import collections

def getdict(n):
	d = {}
	if type(n) is list or type(n) is str:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return '\n'.join(map(str, arr))

def revn(n):
	return int(str(n)[::-1])

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True
(n, m) = mi()
a = li()
s = [0] * (10 ** 5 + 1)
c = [0] * n
t = 0
for i in range(1, n + 1):
	if s[a[-i]] == 1:
		c[n - i] = t
	else:
		s[a[-i]] = 1
		t += 1
		c[n - i] = t
ans = [0] * m
for i in range(m):
	l = ii()
	ans[i] = c[l - 1]
print(wr(ans))


(n, m) = map(int, input().split())
aa = list(map(int, input().split()))
cnt = [True] * 100001
res = []
x = 0
for a in reversed(aa):
	if cnt[a]:
		cnt[a] = False
		x += 1
	res.append(x)
print('\n'.join((str(res[n - int(input())]) for _ in range(m))))


(n, m) = [int(i) for i in input().split()]
arr = [int(i) for i in input().split()]
count_list = [0] * n
set_count = set()
for i in range(n - 1, -1, -1):
	set_count.add(arr[i])
	count_list[i] = len(set_count)
for _ in range(m):
	l = int(input())
	print(count_list[l - 1])


(n, m) = map(int, input().split())
lst = list(map(int, input().split()))
dist = [0] * n
s = set()
for i in range(n - 1, -1, -1):
	s.add(lst[i])
	dist[i] = len(s)
for i in range(m):
	print(dist[int(input()) - 1])


(n, m) = [int(x) for x in input().split()]
q = [int(x) for x in input().split()]
ans = [1] * n
t = dict()
t[q[-1]] = 1
for i in range(n - 1 - 1, -1, -1):
	temp = 0
	try:
		temp = t[q[i]]
	except KeyError:
		t[q[i]] = 1
		temp = 0
	ans[i] = ans[i + 1] + (1 if not temp else 0)
out = []
for i in range(m):
	l = int(input())
	out.append(ans[l - 1])
print('\n'.join(map(str, out)))


(n, m) = [int(i) for i in input().split(' ')]
a = [int(i) for i in input().split(' ')]
l = []
for i in range(m):
	l.append(int(input()))
ans = []
s = {}
cnt = 0
for i in range(n - 1, -1, -1):
	key = a[i]
	if key not in s:
		s[key] = 1
		cnt += 1
	ans.append(cnt)
ans.reverse()
for i in range(m):
	print(ans[l[i] - 1])


from itertools import accumulate
(n, m) = map(int, input().split())
array = list(map(int, input().split()))
dis = [None] * n
dis[-1] = 1
dic = {i: 0 for i in array}
dic[array[-1]] = 1
for i in range(2, n + 1):
	if dic[array[-i]] == 1:
		dis[-i] = 0
	else:
		dis[-i] = 1
		dic[array[-i]] = 1
s = list(accumulate(dis[::-1]))[::-1]
for i in range(m):
	x = int(input())
	print(s[x - 1])


from sys import stdin, stdout
input = stdin.readline
(n, m) = map(int, input().split())
a = [0] + list(map(int, input().split()))
cnt = [0] * (10 ** 5 + 1)
for i in a:
	cnt[i] += 1
dp = [0] * (10 ** 5 + 1)
for i in range(n + 1):
	cnt[a[i]] -= 1
	if i == 0:
		for j in cnt:
			if j:
				dp[0] += 1
	elif not cnt[a[i]]:
		dp[i] = dp[i - 1] - 1
		cnt[a[i]] = 1
	else:
		dp[i] = dp[i - 1]
for i in range(m):
	stdout.write(str(dp[int(input()) - 1]))
	stdout.write('\n')


(n, m) = map(int, input().split(' '))
a = []
a = list(map(int, input().split(' ')))
sol = []
dic = {}
for x in range(n - 1, -1, -1):
	dic.update({a[x]: True})
	sol.append(len(dic))
sol = sol[::-1]
res = []
for x in range(1, m + 1):
	v = int(input())
	res.append(sol[v - 1])
for x in range(0, len(res)):
	print(res[x])


(n, m) = map(int, input().split())
a = [[x, 0] for x in map(int, input().split())]
b = []
for i in range(m):
	b.append(int(input()))
distinct = {}
distinctcount = 0
for i in reversed(range(n)):
	try:
		distinct[a[i][0]] += 1
	except:
		distinct[a[i][0]] = 1
		distinctcount += 1
	a[i][1] = distinctcount
for j in range(m):
	print(a[b[j] - 1][1])


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
l2 = []
dist = 0
ans = dict()
final = []
for i in range(len(l) - 1, -1, -1):
	if ans.get(l[i]) == None:
		dist += 1
		ans[l[i]] = 1
		final.append(dist)
	else:
		final.append(dist)
for i in range(m):
	print(final[n - int(input())])


(n, m) = map(int, input().split(' '))
list = list(map(int, input().split(' ')))
dic = {}
count = 0
len_list = []
list_invert = list[::-1]
for i in list_invert:
	try:
		dic[i]
	except:
		dic[i] = 1
		count += 1
	len_list.append(count)
len_list = len_list[::-1]
for i in range(m):
	a = int(input()) - 1
	print(len_list[a])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
l = []
for i in range(m):
	l.append(int(input()))
V = (10 ** 5 + 1) * [True]
V[a[n - 1]] = False
ans = n * [0]
ans[n - 1] = 1
for i in range(n - 2, -1, -1):
	ans[i] = ans[i + 1]
	if V[a[i]] == True:
		ans[i] += 1
		V[a[i]] = False
for i in range(m):
	print(ans[l[i] - 1])


a1 = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
queries = []
m = a1[1]
for i in range(m):
	queries.append(int(input()))
allIntegers = {}
index = len(l) - 1
total = 0
dp = [0 for i in range(len(l))]
while index >= 0:
	if l[index] not in allIntegers:
		allIntegers[l[index]] = True
		total += 1
	dp[index] = total
	index -= 1
outputString = ''
for i in range(0, m):
	outputString += str(dp[queries[i] - 1]) + '\n'
print(outputString, end='')


from sys import *
(n, m) = [int(x) for x in stdin.readline().rstrip().split()]
numbers = [int(x) for x in stdin.readline().rstrip().split()]
different_numbers = set()
different_numbers_counter = 0
different_numbers_counters = []
for i in reversed(range(len(numbers))):
	number = numbers[i]
	if number not in different_numbers:
		different_numbers_counter += 1
		different_numbers.add(number)
	different_numbers_counters.append(different_numbers_counter)
different_numbers_counters.reverse()
indexes = [int(x) - 1 for x in stdin.read().rstrip().split()]
result = [different_numbers_counters[x] for x in indexes]
stdout.write('\n'.join([str(x) for x in result]))


(szArr, numInt) = map(int, input().split())
sumDif = [0] * szArr
elems = list(map(int, input().split()))
diff = 0
difElem = [0] * 100001
for i in range(szArr):
	if difElem[elems[i]] == 0:
		diff += 1
	difElem[elems[i]] += 1
for i in range(szArr):
	sumDif[i] = diff
	difElem[elems[i]] -= 1
	if difElem[elems[i]] == 0:
		diff -= 1
for i in range(numInt):
	index = int(input())
	print(sumDif[index - 1])


def main():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = set()
	f = []
	for i in range(n - 1, -1, -1):
		b.add(a[i])
		f.append(len(b))
	f.reverse()
	for i in range(m):
		l = int(input())
		print(f[l - 1])
main()


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
hash1 = []
ans = []
for i in range(100001):
	hash1.append(0)
for i in range(n):
	ans.append(0)
ans[n - 1] = 1
hash1[a[n - 1]] = 1
for i in range(n - 2, -1, -1):
	if hash1[a[i]] == 0:
		hash1[a[i]] = 1
		ans[i] = ans[i + 1] + 1
	else:
		ans[i] = ans[i + 1]
for _ in range(m):
	x = int(input())
	print(ans[x - 1])


(n, m) = map(int, input().split())
data = list(map(int, input().split()))
inds = [int(input()) - 1 for _ in range(m)]
sorted_inds = sorted(list(set(inds)))
flags = [False] * 100000
counts = {}
cnt = 0
si = len(sorted_inds) - 1
for di in range(len(data) - 1, -1, -1):
	d = data[di] - 1
	if not flags[d]:
		cnt += 1
	flags[d] = True
	if di == sorted_inds[si]:
		counts[di] = cnt
		si -= 1
for ind in inds:
	print(counts[ind])


(n, m) = tuple(map(int, input().split()))
st = list(map(int, input().split()))
mt = []
for i in range(m):
	mt.append(int(input()))
ls = [0] * max(st)
x = len(set(st))
for i in range(len(st)):
	ls[st[i] - 1] += 1
ps = [0] * len(st)
for i in range(len(st)):
	ps[i] = x
	ls[st[i] - 1] -= 1
	if ls[st[i] - 1] == 0:
		x -= 1
for i in range(len(mt)):
	print(ps[mt[i] - 1])


l = input().split()
(n, m) = (int(l[0]), int(l[1]))
a = list(map(int, input().split()))
s = set()
d = dict()
for i in range(n - 1, -1, -1):
	s.add(a[i])
	d[i] = len(s)
for i in range(m):
	x = int(input())
	print(d[x - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
k = [0] * n
d = {}
c = 0
for i in range(n - 1, -1, -1):
	if a[i] not in d:
		c = c + 1
		d[a[i]] = 1
	k[i] = c
for i in range(0, m):
	k1 = int(input())
	print(k[k1 - 1])


(n, m) = map(int, input().split())
l = [*map(int, input().split())]
s = set()
d = {}
res = [-1] * n
res[n - 1] = 1
d[l[n - 1]] = 1
for i in range(n - 2, -1, -1):
	if l[i] in d:
		res[i] = res[i + 1]
	else:
		d[l[i]] = 1
		res[i] = res[i + 1] + 1
for i in range(m):
	index = int(input())
	print(res[index - 1])


MP = lambda : map(int, input().split())
(n, m) = MP()
arr = input().split()
cnt = set()
ans = list()
for a in reversed(arr):
	cnt.add(a)
	ans.append(len(cnt))
print('\n'.join((str(ans[-int(input())]) for _ in range(m))))


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = [0] * n
b[n - 1] = 1
c = set()
c.add(a[n - 1])
for i in range(n - 2, -1, -1):
	if a[i] not in c:
		b[i] = b[i + 1] + 1
		c.add(a[i])
	else:
		b[i] = b[i + 1]
for j in range(m):
	s = int(input())
	print(b[s - 1])


(n, m) = map(int, input().split())
a = [int(i) for i in input().split()]
ds = [0] * (n + 1)
h = [0] * (10 ** 5 + 1)
for i in range(n - 1, -1, -1):
	if h[a[i]] == 0:
		ds[i] = ds[i + 1] + 1
		h[a[i]] = 1
	else:
		ds[i] = ds[i + 1]
for w in range(m):
	q = int(input())
	print(ds[q - 1])


(n, m) = map(int, input().split())
arr = input().split()
index = [int(input()) for _ in range(m)]
nums = [0] * n
d = {}
for i in range(len(arr) - 1, -1, -1):
	if arr[i] not in d:
		d[arr[i]] = 1
		nums[n - i - 1] += 1
	if len(nums) >= 2:
		nums[n - i - 1] += nums[n - i - 2]
print(*[nums[len(nums) - index[i]] for i in range(len(index))], sep='\n')


from sys import *
(n, m) = [int(x) for x in stdin.readline().rstrip().split()]
a = [int(x) for x in stdin.readline().rstrip().split()]
s = set([])
answer = list(range(n + 1))
answer[n] = 0
for i in range(n - 1, -1, -1):
	s.add(a[i])
	answer[i] = len(s)
for i in range(m):
	l = int(input()) - 1
	print(answer[l])


result = []
(n, m) = input().split()
n = int(n)
m = int(m)
number = list(map(int, input().strip().split()))
number.reverse()
numset = set()
j = 0
L = []
for data in number:
	numset.add(data)
	lenset = len(numset)
	j += 1
	if lenset != j:
		j -= 1
	L.append(j)
L.reverse()
for i in range(m):
	asknum = int(input())
	result.append(L[asknum - 1])
for k in range(m):
	print(result[k])


(n, m) = list(map(int, input().split(' ')))
indice_repeticao = list(map(int, input().split(' ')))
numeros_vistos = [0 for _ in range(max(indice_repeticao) + 1)]
acumulador_numeros_vistos = [0 for _ in range(n + 1)]
acumulador_numeros_vistos[n - 1] = 1
numeros_vistos[indice_repeticao[n - 1]] = True
indice_inicial = n - 2
for i in range(indice_inicial, -1, -1):
	atual = indice_repeticao[i]
	acumulador_numeros_vistos[i] = acumulador_numeros_vistos[i + 1]
	if not numeros_vistos[atual]:
		numeros_vistos[atual] = True
		acumulador_numeros_vistos[i] += 1
for i in range(m):
	q = int(input())
	print(acumulador_numeros_vistos[q - 1])


(n, m) = list(map(int, input().split()))
A = []
In = input().split()[::-1]
Set = set()
for val in In:
	Set.add(val)
	A.append(len(Set))
A = [0] + A[::-1]
for _ in range(m):
	N = int(input())
	print(A[N])


def sereja_and_suffixes(n, b):
	a = set()
	for c in range(1, n + 1):
		a.add(b[-c])
		b[-c] = str(len(a))
	print('\n'.join([b[int(input()) - 1] for c in range(i)]))
(n, i) = list(map(int, input().split()))
x = list(map(str, input().split()))
sereja_and_suffixes(n, x)


X = list(map(int, input().split()))
(Numbers, MySet) = (input().split(), set())
for i in range(X[0] - 1, -1, -1):
	MySet.add(Numbers[i])
	Numbers[i] = len(MySet)
print(*[Numbers[int(input()) - 1] for i in range(X[1])], sep='\n')


(n, m) = map(int, input().split())
a = input().split()
a2 = [0] * n
s = set()
for num in range(n - 1, -1, -1):
	s.add(a[num])
	a2[num] = str(len(s))
print('\n'.join([a2[int(input()) - 1] for _ in range(m)]))


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
num = set()
k = [0] * n
for i in range(len(a) - 1, -1, -1):
	num.add(a[i])
	k[i] = len(num)
for i in range(m):
	l = int(input())
	print(k[l - 1])


import sys
import itertools
import collections

def rs(x=''):
	return sys.stdin.readline().strip() if len(x) == 0 else input(x).strip()

def ri(x=''):
	return int(rs(x))

def rm(x=''):
	return map(str, rs(x).split())

def rl(x=''):
	return rs(x).split()

def rmi(x=''):
	return map(int, rs(x).split())

def rli(x=''):
	return [int(x) for x in rs(x).split()]

def println(val):
	sys.stdout.write(str(val) + '\n')

def solve(testCase):
	(n, m) = rmi()
	a = rli()
	a = a[::-1]
	queries = [ri() for _ in range(m)]
	distincts = []
	s = set()
	for i in range(n):
		s.add(a[i])
		distincts += [len(s)]
	distincts = distincts[::-1]
	for query in queries:
		query -= 1
		print(distincts[query])
for _ in range(ri() if 0 else 1):
	solve(_ + 1)


(x, y) = map(int, input().split())
a = list(map(int, input().split()))
p = {}
o = [0] * 100001
c = 0
for i in reversed(range(x)):
	if o[a[i]] == 0:
		o[a[i]] = 1
		c += 1
	p[i + 1] = c
for _ in range(y):
	print(p[int(input())])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
l = len(a)
b = {}
d = {}
for i in range(l - 1, -1, -1):
	d[a[i]] = 1
	b[i] = len(d)
while m:
	p = int(input()) - 1
	print(b[p])
	m -= 1


(n, m) = map(int, input().split())
arr = [int(i) for i in input().split()]
myset = set()
k = 0
ulst = []
for i in range(n - 1, -1, -1):
	if arr[i] not in myset:
		k += 1
		myset.add(arr[i])
	ulst.append(k)
for _ in range(m):
	ind = int(input())
	print(ulst[n - ind])


(n, m) = [int(x) for x in input().split()]
array = [int(x) for x in input().split()]
ints = []
for _ in range(m):
	ints.append(int(input()))
memo = [0] * len(array)
added = set()
k = 0
for i in range(len(array) - 1, -1, -1):
	if array[i] not in added:
		k += 1
		added.add(array[i])
	memo[i] = k
for pos in ints:
	print(memo[pos - 1])


(n, m) = [int(s) for s in input().split(' ')]
arr = [int(s) for s in input().split(' ')]
a = [0] * n
a[n - 1] = 1
dct = {arr[len(arr) - 1]: 1}
for i in range(len(arr) - 2, -1, -1):
	try:
		if dct[arr[i]] == 1:
			a[i] = a[i + 1]
	except KeyError:
		dct[arr[i]] = 1
		a[i] = a[i + 1] + 1
for i in range(m):
	l = int(input())
	print(a[l - 1])


(n, m) = input().split()
(n, m) = (int(n), int(m))
a = list(map(int, input().split()))
q = [0] * m
disct = 0
for i in range(0, m):
	temp = int(input())
	q[i] = temp
x = [0] * (10 ** 5 + 1)
for i in a:
	if x[i] == 0:
		disct += 1
	x[i] += 1
dp = [0] * n
for i in range(0, n):
	dp[i] = disct
	x[a[i]] -= 1
	if x[a[i]] == 0:
		disct -= 1
for i in q:
	print(dp[i - 1])


res = ''
(n, m) = map(int, input().split())
mat = list(map(int, input().split()))[::-1]
s = set()
step = 0
for i in range(n):
	if not mat[i] in s:
		step += 1
		s.add(mat[i])
	mat[i] = step
for _ in range(m):
	res += str(mat[n - int(input())]) + '\n'
print(res[0:-1])


(n, m) = map(int, input().split())
a = [int(i) for i in input().split()]
dp = [None for _ in range(n)]
set_ = set()
for i in range(n - 1, -1, -1):
	set_.add(a[i])
	dp[i] = len(set_)
ans = []
for _ in range(m):
	l = int(input())
	ans.append(dp[l - 1])
ans = '\n'.join([str(i) for i in ans])
print(ans)


(n, m) = map(int, input().split())
n_list = list(map(int, input().split()))
m_list = []
for i in range(m):
	m_list.append(int(input()))
c = 0
counts = [0] * n
dist = [0] * 100000
for i in range(n - 1, -1, -1):
	if dist[n_list[i] - 1]:
		counts[i] = c
	else:
		c += 1
		counts[i] = c
		dist[n_list[i] - 1] = 1
for i in m_list:
	print(counts[i - 1])


(n, m) = map(int, input().split())
(a, l) = (list(map(int, input().split())), [int(input()) for i in range(m)])
(b, p, c) = (set(), [0] * n, 0)
for i in range(len(a) - 1, -1, -1):
	if a[i] not in b:
		b.add(a[i])
		c += 1
	p[i] = c
for x in l:
	print(p[x - 1])


(n, m) = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]
c = [0] * n
s = set()
for i in range(n - 1, -1, -1):
	s.add(a[i])
	c[i] = len(s)
for _ in range(m):
	l = int(input())
	print(c[l - 1])


from collections import Counter
import string
import math

def array_int():
	return [int(i) for i in input().split()]

def vary(number_of_variables):
	if number_of_variables == 1:
		return int(input())
	if number_of_variables >= 2:
		return map(int, input().split())

def makedict(var):
	return dict(Counter(var))
mod = 1000000007
if 1:
	(n, q) = vary(2)
	num = array_int()
	tt = set()
	dp = [0] * n
	dp[n - 1] = 1
	tt.add(num[n - 1])
	for i in range(n - 2, -1, -1):
		if num[i] in tt:
			dp[i] = dp[i + 1]
			continue
		else:
			dp[i] = dp[i + 1] + 1
			tt.add(num[i])
	for i in range(q):
		ttt = vary(1)
		if ttt == 1:
			print(dp[0])
			continue
		if ttt == n:
			print(1)
			continue
		print(dp[ttt - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
s = set()
cnt = 0
d = [0] * n
for i in range(n - 1, -1, -1):
	if a[i] not in s:
		s.add(a[i])
		cnt += 1
	d[i] = cnt
for _ in range(m):
	j = int(input())
	print(d[j - 1])


import sys
inp = sys.stdin.readline
out = print
(n, m) = map(int, inp().split())
a = [int(i) for i in inp().split()]
a.insert(0, 0)
ans = [0 for i in range(n + 1)]
s = set()
for i in range(n, 0, -1):
	s.add(a[i])
	ans[i] = len(s)
for _ in range(m):
	out(ans[int(inp())])


inputs = input().split()
n = int(inputs[0])
m = int(inputs[1])
num_list = [int(x) for x in input().split()]
queries = []
for i in range(m):
	queries.append(int(input()))
saved = []
hash_set = set()
for num in reversed(num_list):
	hash_set.add(num)
	saved.append(len(hash_set))
for q in queries:
	print(saved[n - q])


(a, b) = [int(i) for i in input().split()]
arr = [int(i) for i in input().split()]
s = set()
dp = [0] * a
count = 0
for i in range(a - 1, -1, -1):
	if arr[i] not in s:
		count += 1
		dp[i] = count
		s.add(arr[i])
	else:
		dp[i] = count
for i in range(b):
	n = int(input())
	print(dp[n - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
ans = set()
ans.add(a[n - 1])
ans1 = [0] * n
ans1[n - 1] = 1
for i in range(n - 2, -1, -1):
	if a[i] not in ans:
		ans.add(a[i])
		ans1[i] = ans1[i + 1] + 1
	else:
		ans1[i] = ans1[i + 1]
b = []
for i in range(m):
	b.append(int(input()) - 1)
for i in range(m):
	print(ans1[b[i]])


from sys import stdin, stdout
(n, m) = map(int, stdin.readline().split())
l = list(map(int, stdin.readline().split()))
idx = [0] * n
c = 0
chk = {}
for i in list(set(l)):
	chk[i] = 0
for i in range(n - 1, -1, -1):
	if chk[l[i]] == 0:
		c += 1
		idx[i] = c
		chk[l[i]] = 1
	elif chk[l[i]] == 1:
		idx[i] = c
for i in range(m):
	print(idx[int(stdin.readline()) - 1])


(n, m) = list(map(int, input().strip().split(' ')))
arr = list(map(int, input().strip().split(' ')))
res = [0 for i in range(n)]
ans = []
s = [False for i in range(100001)]
num = 0
for i in range(n - 1, -1, -1):
	if not s[arr[i]]:
		s[arr[i]] = True
		num += 1
	res[i] = num
for _ in range(m):
	t = int(input())
	ans.append(str(res[t - 1]))
print('\n'.join(ans))


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
l = []
last = set()
for i in reversed(a):
	last.add(i)
	l.append(len(last))
for i in range(m):
	t = int(input())
	print(l[n - t])


from collections import defaultdict
from sys import stdin, stdout
(n, k) = map(int, stdin.readline().split())
a = list(map(int, stdin.readline().split()))
temp = [False] * 100000
ans = defaultdict(lambda : 0)
val = 0
for i in range(n - 1, -1, -1):
	if temp[a[i] - 1] == False:
		val += 1
		temp[a[i] - 1] = True
	ans[i] = val
for _ in range(k):
	t = int(stdin.readline())
	print(ans[t - 1])


(n, m) = map(int, input().split())
beauty_num = [int(i) for i in input().split()]
tf = [False] * 1000001
answer = 0
result = [''] * n
for i in range(n):
	if tf[beauty_num[n - 1 - i]] == False:
		answer += 1
		tf[beauty_num[n - 1 - i]] = True
	result[n - 1 - i] = answer
for i in range(m):
	ai = int(input())
	print(result[ai - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
d = {}
b = [0] * n
for i in range(n - 1, -1, -1):
	d[a[i]] = 0
	b[i] = len(d)
for i in range(m):
	t = int(input())
	print(b[t - 1])


import math
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
k = [0] * n
s = set()
for i in range(n - 1, -1, -1):
	s.add(l[i])
	k[i] = len(s)
for i in range(m):
	print(k[int(input()) - 1])


import sys

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def rinput():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
dp = set()
for i in range(n - 1, -1, -1):
	dp.add(l[i])
	l[i] = len(dp)
for _ in range(m):
	m = int(input())
	print(l[m - 1])


from sys import *
(n, m) = (int(z) for z in stdin.readline().split())
arr = [int(z) for z in stdin.readline().split()]
dp = [0] * n
dis = set()
for i in range(n - 1, -1, -1):
	dis.add(arr[i])
	dp[i] = len(dis)
for i in range(m):
	k = int(stdin.readline())
	stdout.write(str(dp[k - 1]) + '\n')


import sys
it = iter(sys.stdin.read().splitlines())
(n, m) = [int(x) for x in next(it).split()]
nums = list(next(it).split())
uniqueNumbers = set()
unique = [0] * n
for i in range(len(nums) - 1, -1, -1):
	uniqueNumbers.add(nums[i])
	unique[i] = len(uniqueNumbers)
for i in range(0, m):
	index = int(next(it))
	print(unique[index - 1])


import sys
it = iter(sys.stdin.read().splitlines())
(n, k) = [int(x) for x in next(it).split()]
nList = [int(x) for x in next(it).split()]
newNumbers = []
freq = {}
unique = [0] * (n + 1)
for x in range(n):
	freq[nList[x]] = 0
for y in range(n - 1, -1, -1):
	freq[nList[y]] = freq[nList[y]] + 1
	if freq[nList[y]] == 1:
		unique[y] = unique[y + 1] + 1
	else:
		unique[y] = unique[y + 1]
for x in range(k):
	n = int(next(it))
	print(unique[n - 1])


(n, m) = map(int, input().split())
array = list(map(int, input().split()))
ans = [0] * (n + 1)
b = set()
for i in range(len(array) - 1, -1, -1):
	ans[i] = ans[i + 1]
	if array[i] not in b:
		ans[i] += 1
		b.add(array[i])
res = []
for i in range(m):
	p = int(input())
	res.append(str(ans[p - 1]))
print('\n'.join(res))


(n, m) = [int(a) for a in input().split()]
arr = [int(a) for a in input().split()]
Dict = {}
Dict[n - 1] = 1
Set = set()
Set.add(arr[-1])
Len = 1
for index in range(n - 2, 0, -1):
	if arr[index] in Set:
		Dict[index] = Len
	else:
		Set.add(arr[index])
		Len += 1
		Dict[index] = Len
Dict[0] = len(set(arr))
for numb in range(m):
	print(Dict[int(input()) - 1])


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
ans = [0] * n
s = set()
ans[-1] = 1
s.add(l[-1])
for i in range(n - 2, -1, -1):
	if l[i] not in s:
		ans[i] = ans[i + 1] + 1
		s.add(l[i])
	else:
		ans[i] = ans[i + 1]
for i in range(m):
	print(ans[int(input()) - 1])


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
que = []
for i in range(m):
	que.append(int(input()))
dic = {}
res = [0 for i in range(n)]
p = 0
for i in range(n - 1, -1, -1):
	if arr[i] not in dic:
		dic[arr[i]] = 1
		p += 1
	res[i] = p
for q in que:
	print(res[q - 1])


import math

def s():
	(n, m) = [int(x) for x in input().split(' ')]
	inpt = [int(x) for x in input().split(' ')]
	arr = [0 for x in range(n)]
	chr_set = set()
	temp = 0
	for i in range(n - 1, -1, -1):
		if inpt[i] not in chr_set:
			temp += 1
			chr_set.add(inpt[i])
		arr[i] = temp
	for i in range(m):
		l = int(input())
		print(arr[l - 1])
s()


arr = []
vis = [0] * 100001
ans = [0] * 100000
query = []
num = 0
(N, Q) = map(int, input().split())
arr = list(map(int, input().split()))
for i in range(N - 1, -1, -1):
	if vis[arr[i]] == 0:
		vis[arr[i]] = 1
		num = num + 1
	ans[i] = num
for i in range(Q):
	x = int(input())
	x = x - 1
	print(ans[x])


from collections import defaultdict
from sys import stdin, stdout
(n, m) = map(int, stdin.readline().split())
arr = list(map(int, stdin.readline().split()))
dict = defaultdict(int)
count = [0 for i in range(n)]
count[n - 1] = 1
dict[arr[n - 1]] = 1
for i in range(n - 2, -1, -1):
	if dict[arr[i]] == 0:
		dict[arr[i]] = 1
		count[i] += count[i + 1] + dict[arr[i]]
	else:
		count[i] = count[i + 1]
for i in range(m):
	a = int(stdin.readline())
	print(count[a - 1])


import sys
(n, m) = map(int, sys.stdin.readline().split())
an = list(map(int, sys.stdin.readline().split()))
counts = [0] * n
id = n - 1
s = set()
while id >= 0:
	s.add(an[id])
	counts[id] = len(s)
	id -= 1
ans = ''
for i in range(m):
	l = int(input())
	ans += str(counts[l - 1])
	if i != m - 1:
		ans += '\n'
print(ans)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
dp = [0 for _ in range(len(a))]
s = set()
for i in range(len(a) - 1, -1, -1):
	s.add(a[i])
	dp[i] = len(s)
for _ in range(m):
	c = int(input())
	print(dp[c - 1])


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
(j, h, k) = ([], {}, 0)
for i in range(n):
	if l[n - 1 - i] not in h:
		k += 1
		h[l[n - 1 - i]] = 1
	j.append(k)
for f in range(m):
	n1 = int(input())
	print(j[n - n1])


import sys
input = sys.stdin.readline
prnt = sys.stdout.write
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
sf = [1]
s = set()
s.add(a[n - 1])
for i in range(n - 2, -1, -1):
	s.add(a[i])
	sf.append(len(s))
sf = sf[::-1]
for i in range(m):
	x = int(input())
	print(sf[x - 1])


line1 = input()
(n, m) = [int(x) for x in line1.split()]
line2 = input()
code = [x for x in line2.split()]
code_set = set()
count_list = [0 for _ in range(n)]
count = 0
for (index, c) in enumerate(code[::-1]):
	if c not in code_set:
		code_set.add(c)
		count += 1
	count_list[index] = count
count_list.reverse()
for i in range(m):
	index = int(input())
	print(count_list[index - 1])


import sys
(n, m) = map(int, sys.stdin.readline().split())
A = list(map(int, sys.stdin.readline().split()))
Ans = [1]
E = {}
E[A[-1]] = 1
for i in range(n - 2, -1, -1):
	if A[i] in E:
		Ans.append(Ans[-1])
	else:
		E[A[i]] = 1
		Ans.append(Ans[-1] + 1)
Answer = ''
for i in range(m):
	x = int(sys.stdin.readline())
	x -= 1
	x = n - 1 - x
	Answer += str(Ans[x]) + '\n'
sys.stdout.write(Answer)


(n, m) = map(int, input().split())
a = [int(x) for x in input().split()]
b = [0] * m
d = [0] * n
for i in range(m):
	b[i] = int(input())
hx = [0] * 100010
ans = 0
for i in range(n):
	if hx[a[n - 1 - i]] == 0:
		hx[a[n - 1 - i]] = 1
		ans += 1
	d[n - 1 - i] = str(int(ans))
for i in range(m):
	print(d[b[i] - 1])


def solve():
	from collections import Counter
	(n, m) = map(int, input().strip().split())
	l = list(map(int, input().strip().split()))
	c = Counter(l)
	lc = list(c)
	lcl = len(lc)
	r = [lcl] * n
	for i in range(n):
		c[l[i]] -= 1
		if c[l[i]] >= 1:
			r[i] = lcl
		else:
			r[i] = lcl
			lcl -= 1
	for i in range(m):
		x = int(input())
		print(r[x - 1])
solve()


from sys import stdin
from collections import defaultdict
(n, m) = [int(x) for x in stdin.readline().split()]
nums = list(map(int, stdin.readline().split()))
d = set()
d.add(nums[-1])
nums[-1] = 1
for i in range(len(nums) - 2, -1, -1):
	if nums[i] in d:
		newnumber = 0
	else:
		newnumber = 1
		d.add(nums[i])
	nums[i] = nums[i + 1] + newnumber
ans = ''
for i in range(0, m):
	query = int(input())
	ans += str(nums[query - 1]) + '\n'
print(ans)


(n, m) = map(int, input().split())
a = [int(x) for x in input().split()]
a.reverse()
answer = []
b = [0] * n
b[0] = 1
c = set()
c.add(a[0])
for i in range(1, n):
	b[i] = b[i - 1]
	if a[i] not in c:
		c.add(a[i])
		b[i] += 1
for _ in range(m):
	l = int(input())
	print(b[n - l])


from sys import *
(n, m) = (int(i) for i in stdin.readline().split())
a = [i for i in stdin.readline().split()]
s = set()
for i in range(n - 1, -1, -1):
	s.add(a[i])
	a[i] = len(s)
for i in range(m):
	stdout.write(str(a[int(stdin.readline()) - 1]) + '\n')


(n, m) = input().split()
n = int(n)
m = int(m)
l = list(map(int, input().split()))
d = max(l)
a = [0] * (d + 1)
s = set(l)
k = len(s)
g = []
h = []
for i in l:
	a[i] += 1
for i in range(m):
	h.append(int(input()))
for i in range(n):
	if a[l[i]] > 1:
		a[l[i]] -= 1
		g.append(k)
	else:
		g.append(k)
		k = k - 1
for i in range(m):
	print(g[h[i] - 1])


(n, m) = input().split()
n = int(n)
m = int(m)
a = [[int(i), 0] for i in input().split()]
s = {a[n - 1][0]}
a[n - 1][1] = 1
for i in range(n - 2, -1, -1):
	s.add(a[i][0])
	a[i][1] = len(s)
otv = []
for i in range(m):
	l = int(input())
	otv += [a[l - 1][1]]
for i in otv:
	print(i)


(n, m) = [int(i) for i in input().split()]
arr = [0] * 100005
res = [0] * n
ls = [int(i) for i in input().split()]
arr[ls[n - 1]] = 1
res[n - 1] = 1
for i in range(n - 2, -1, -1):
	if arr[ls[i]] == 0:
		arr[ls[i]] = arr[ls[i + 1]] + 1
		res[i] = arr[ls[i]]
	else:
		arr[ls[i]] = arr[ls[i + 1]]
		res[i] = arr[ls[i]]
for i in range(m):
	idx = int(input())
	print(res[idx - 1])


import collections as cc
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
s = set()
a = [0] * n
for i in range(n - 1, -1, -1):
	s.add(l[i])
	a[i] = len(s)
for i in range(m):
	print(a[int(input()) - 1])


(n, m) = [int(x) for x in input().split()]
numbers = input().split()
differents = set()
cont = []
for i in range(n - 1, -1, -1):
	differents.add(int(numbers[i]))
	cont.append(len(differents))
for i in range(m):
	index = int(input())
	print(cont[n - index])


import sys
input = lambda : sys.stdin.readline()
(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
mark = set()
ans = []
for i in range(n - 1, -1, -1):
	mark.add(a[i])
	ans.append(len(mark))
for i in range(m):
	print(ans[n - int(input())])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
dp = [0 for x in range(n)]
s = {a[-1]}
dp[-1] = 1
for i in range(n - 2, -1, -1):
	if a[i] in s:
		dp[i] = dp[i + 1]
	else:
		dp[i] = dp[i + 1] + 1
		s.add(a[i])
for _ in range(m):
	i = int(input())
	print(dp[i - 1])


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
d = {}
y = [0] * len(x)
sum = 0
for i in range(len(x) - 1, -1, -1):
	try:
		d[x[i]] += 1
	except:
		d[x[i]] = 1
		sum += 1
	y[i] = sum
for __ in range(m):
	t = int(input())
	print(y[t - 1])


(n, m) = map(int, input().split(' '))
l = list(map(int, input().split(' ')))
b = set()
for i in range(len(l) - 1, -1, -1):
	b.add(l[i])
	l[i] = len(b)
for i in range(m):
	c = int(input())
	print(l[c - 1])


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
l.reverse()
op = []
my = set()
for i in range(n):
	my.add(l[i])
	op.append(len(my))
op.reverse()
for i in range(m):
	k = int(input())
	print(op[k - 1])


(n_values, n_tests) = map(int, input().split())
values = list(map(int, input().split()))
distinct_values = [0] * 100010
found_values = [False] * 100010
for i in range(n_values - 1, -1, -1):
	value = values[i]
	if not found_values[value]:
		distinct_values[i + 1] += 1
	found_values[value] = True
for i in range(n_values, -1, -1):
	distinct_values[i] += distinct_values[i + 1]
for i in range(n_tests):
	target_index = int(input())
	print(distinct_values[target_index])


(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
f = [0] * n
memo = {}
tot = 0
i = n - 1
while i >= 0:
	if a[i] not in memo:
		tot += 1
		memo[a[i]] = 1
	f[i] = tot
	i -= 1
for i in range(m):
	x = int(input()) - 1
	print(f[x])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
l = [0] * (m + 1)
v = [0] * 100001
f = [0] * (n + 1)
b = int()
for i in range(m):
	l[i] = int(input())
for i in range(n - 1, -1, -1):
	if v[a[i]] == 0:
		v[a[i]] += 1
		b += 1
		f[i] = b
	else:
		f[i] = b
for i in range(m):
	print(f[l[i] - 1])


(n, m) = map(int, input().split())
mark = [0] * (10 ** 5 + 1)
a = list(map(int, input().split()))
distinct = [1] * n
mark[a[-1]] = 1
for i in range(len(a) - 2, -1, -1):
	if mark[a[i]] == 0:
		distinct[i] = distinct[i + 1] + 1
		mark[a[i]] += 1
	else:
		distinct[i] = distinct[i + 1]
for _ in range(m):
	num = int(input())
	print(distinct[num - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
uniq = {}
l = [int(input()) for i in range(m)]
l2 = []
for i in range(n):
	uniq[a[i]] = uniq.get(a[i], 0) + 1
b = len(uniq)
for i in range(n):
	l2.append(b)
	uniq[a[i]] -= 1
	if uniq[a[i]] == 0:
		dump = uniq.pop(a[i])
		b -= 1
for i in range(m):
	print(l2[l[i] - 1])


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
dp = [0] * n
(dp[-1], seen) = (1, set())
seen.add(arr[-1])
for i in range(n - 2, -1, -1):
	if arr[i] not in seen:
		seen.add(arr[i])
		dp[i] = dp[i + 1] + 1
	else:
		dp[i] = dp[i + 1]
for _ in range(m):
	q = int(input())
	print(dp[q - 1])


(n, m) = map(int, input().split())
A = list(map(int, input().split()))
L = []
for _ in range(m):
	L.append(int(input()))
S = set()
counts = []
for x in reversed(A):
	S.add(x)
	counts.append(len(S))
for l in L:
	print(counts[n - l])


(n, m) = map(int, input().split())
li = [int(x) for x in input().split()]
d = {}
distinct = [0] * (n - 1) + [1]
d[li[n - 1]] = 1
for i in range(n - 2, -1, -1):
	if d.get(li[i], 0) == 0:
		distinct[i] = distinct[i + 1] + 1
		d[li[i]] = 1
	else:
		distinct[i] = distinct[i + 1]
for i in range(m):
	l = int(input())
	print(distinct[l - 1])


(n, m) = map(int, input().split())
(set_size, elements) = ({}, set())
for (i, a) in zip(reversed(range(1, n + 1)), reversed(list(map(int, input().split())))):
	elements.add(a)
	set_size[i] = len(elements)
print('\n'.join((str(set_size[int(input())]) for _ in range(m))))


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
d1 = dict()
suff = [0 for i in range(n)]
for i in range(n - 1, -1, -1):
	if arr[i] not in d1:
		suff[i] = 1
		d1[arr[i]] = 1
summ = [0 for i in range(0, n)]
summ[n - 1] = 1
for i in range(n - 2, -1, -1):
	if suff[i] == 1:
		summ[i] = summ[i + 1] + 1
	elif suff[i] == 0:
		summ[i] = summ[i + 1]
while m != 0:
	q = int(input())
	print(summ[q - 1])
	m -= 1


(n, m) = map(int, input().split())
s = list(map(int, input().split()))
c = 0
e = set()
for i in range(n - 1, -1, -1):
	if s[i] in e:
		s[i] = c
	else:
		c += 1
		e.add(s[i])
		s[i] = c
a = ''
for i in range(m):
	a += str(s[int(input()) - 1]) + '\n'
print(a)


def Gree():
	(n, m) = map(int, input().split())
	number = list(map(int, input().split()))
	res = [0] * n
	s = set()
	for i in range(n - 1, -1, -1):
		s.add(number[i])
		res[i] = len(s)
	i = 0
	while i < m:
		print(res[int(input()) - 1])
		i += 1
Gree()


import bisect
line = input()
words = []
for word in line.split():
	words.append(word)
n = int(words[0])
m = int(words[1])
line = input()
v = []
for word in line.split():
	v.append(int(word))
dp = [1] * n
mySet = {0}
for i in range(n - 1, -1, -1):
	mySet.add(v[i])
	dp[i] = len(mySet) - 1
answer = []
for i in range(m):
	question = int(input())
	question -= 1
	answer.append(dp[question])
for a in answer:
	print(a)


from collections import defaultdict

def main():
	read_many = lambda type_: list(map(type_, input().split()))
	(N, M) = read_many(int)
	numbers = read_many(int)
	dnumbers = [1] * N
	last_number = numbers[-1]
	visited = defaultdict(lambda : False)
	visited[last_number] = True
	for i in range(N - 2, -1, -1):
		number = numbers[i]
		if visited[number]:
			dnumbers[i] = dnumbers[i + 1]
		else:
			visited[number] = True
			dnumbers[i] = dnumbers[i + 1] + 1
	output = []
	for _ in range(M):
		q = int(input()) - 1
		output.append(str(dnumbers[q]))
	print('\n'.join(output))
main()


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
dp = [0] * (n + 1)
s = set()
s.add(l[n - 1])
dp[n - 1] = 1
for i in range(n - 2, -1, -1):
	s.add(l[i])
	dp[i] = len(s)
for i in range(m):
	x = int(input())
	print(dp[x - 1])


nn = list(map(int, input().rstrip().split()))
n = nn[0]
m = nn[1]
arr = list(map(int, input().rstrip().split()))
arrnumb = []
for i in range(0, m):
	number = int(input())
	arrnumb.append(number - 1)
dictt = dict()
arrcnt = [0] * n
summ = 0
for i in range(n - 1, -1, -1):
	dictt.setdefault(arr[i], 0)
	if dictt[arr[i]] == 0:
		summ += 1
		arrcnt[i] = summ
	else:
		arrcnt[i] = summ
	dictt[arr[i]] += 1
for i in arrnumb:
	print(arrcnt[i])


a = [int(x) for x in input().split(' ')]
b = [int(x) for x in input().split(' ')]
(c, d) = ([0 for x in range(len(b))], set())
for x in range(len(b) - 1, -1, -1):
	d.add(b[x])
	c[x] = len(d)
for x in range(a[1]):
	e = int(input())
	print(c[e - 1])


(n, m) = map(int, input().split())
serials = list(map(int, input().split()))
records = [1] * len(serials)
girls = set()
count = 0
for i in reversed(range(len(serials))):
	if serials[i] not in girls:
		girls.add(serials[i])
		count += 1
	records[i] = count
for _ in range(m):
	print(records[int(input()) - 1])


def f(n, data):
	out = []
	s = set()
	for i in range(n):
		s.add(data[-(i + 1)])
		out.append(len(s))
	return out
(n, m) = map(int, input().split())
data = list(map(int, input().split()))
result = f(n, data)
for i in range(m):
	sql = int(input())
	print(result[-sql])


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
s = set()
l2 = [0] * len(l)
l.reverse()
for (i, e) in enumerate(l):
	if not e in s:
		l2[i] = 1
		s.add(e)
for i in range(1, len(l2)):
	l2[i] += l2[i - 1]
l2.reverse()
for i in range(m):
	a = int(input())
	print(l2[a - 1])


from collections import defaultdict
(n, m) = map(int, input().split())
a = []
a.insert(0, 0)
b = list(map(int, input().split()))
b.insert(0, 0)
s = set()
for i in range(n, -1, -1):
	s.add(b[i])
	a.append(len(s))
a.reverse()
m -= 1
while m > -1:
	m -= 1
	print(a[int(input())])


(n, m) = map(int, input().split())
l = map(int, input().split())
l = list(l)
d = {}
p = [0] * n
q = len(set(l))
r = []
for item in l:
	d[item] = d.get(item, 0) + 1
for k in range(n):
	d[l[k]] -= 1
	p[k] = q
	if d[l[k]] == 0:
		q -= 1
for i in range(m):
	u = int(input())
	r.append(p[u - 1])
for item in r:
	print(item)


(n, m) = list(map(int, input().split()))
arr = list(map(int, input().split()))
visited = [False for _ in range(100005)]
dp = [0 for _ in range(n + 1)]
dp[-1] = 1
visited[arr[-1]] = True
for i in range(n - 1, 0, -1):
	if visited[arr[i - 1]]:
		dp[i] = dp[i + 1]
	else:
		dp[i] = dp[i + 1] + 1
		visited[arr[i - 1]] = True
for _ in range(m):
	q = int(input())
	print(dp[q])


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
check = [0] * (pow(10, 5) + 1)
res = {}
for i in range(n - 1, -1, -1):
	if check[a[i]] == 0:
		check[a[i]] = 1
		if i + 1 > n - 1:
			res[i] = 1
		else:
			res[i] = res[i + 1] + 1
	else:
		res[i] = res[i + 1]
for i in range(m):
	num = int(input())
	print(res[num - 1])


import sys
input = sys.stdin.readline

def main():
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	L = len(l)
	r = [1] * L
	s = {l[-1]}
	for i in range(L - 2, -1, -1):
		if l[i] in s:
			r[i] = r[i + 1]
		else:
			r[i] = r[i + 1] + 1
			s.add(l[i])
	for _ in range(m):
		print(r[int(input()) - 1])
main()


(n, m) = map(int, input().split())
(set_size, elements, l) = ({}, set(), 0)
for (i, a) in zip(range(n, 0, -1), reversed(list(map(int, input().split())))):
	if a not in elements:
		elements.add(a)
		l += 1
	set_size[i] = l
output = []
for _ in range(m):
	output.append(str(set_size[int(input())]))
print('\n'.join(output))


sizes = input().split()
n = int(sizes[0])
m = int(sizes[1])
array = [int(i) for i in input().split()]
indices = [int(input()) for _ in range(m)]
newlist = {}
other_list = []
while array:
	newlist[array.pop()] = 1
	other_list += [len(newlist)]
for i in indices:
	print(other_list[n - i])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
result = []
s = set()
for i in range(n - 1, -1, -1):
	s.add(a[i])
	result.append(len(s))
for _ in range(m):
	j = int(input())
	print(result[n - j])


o = input().split()
n = int(o[0])
m = int(o[1])
a = [int(i) for i in input().split()]
flag = [0] * 100005
flag[a[n - 1]] = 1
dp = [0] * n
dp[n - 1] = 1
for i in range(n - 2, -1, -1):
	if flag[a[i]]:
		dp[i] = dp[i + 1]
	else:
		dp[i] = dp[i + 1] + 1
	flag[a[i]] = 1
for i in range(m):
	l = int(input())
	print(dp[l - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
s = set()
for i in range(n - 1, -1, -1):
	s.add(a[i])
	a[i] = len(s)
for k in range(m):
	vv = int(input()) - 1
	print(a[vv])


from sys import stdin

def ii():
	return int(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def li():
	return list(mi())
p = [1] * 100005
(n, m) = mi()
a = li()
a = a[::-1]
x = 0
s = []
for i in range(n):
	if p[a[i]]:
		x += 1
		p[a[i]] = 0
	s.append(x)
s = s[::-1]
for _ in range(m):
	print(s[ii() - 1])


(n, m) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
mini = n - 1
queries = []
for i in range(m):
	x = int(input())
	queries.append(x)
	mini = min(mini, x)
d = {}
dp = [0] * n
c = 0
for i in range(n - 1, mini - 2, -1):
	if a[i] not in d:
		d[a[i]] = True
		c += 1
	dp[i] = c
for q in queries:
	print(dp[q - 1])


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
p = []
s = set()
c = 0
for i in range(n):
	if l[n - 1 - i] not in s:
		s.add(l[n - 1 - i])
		c += 1
	p.append(c)
for i in range(m):
	k = int(input())
	print(p[-k])


(N, m) = map(int, input().split())
l1 = list(map(int, input().split()))
s = set()
result = []
for i in range(N - 1, -1, -1):
	s.add(l1[i])
	result.append(len(s))
for i in range(m):
	n = int(input())
	print(result[-n])


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	(n, m) = LI()
	a = LI()
	q = [I() for _ in range(m)]
	w = [0] * n
	s = set([a[-1]])
	w[-1] = 1
	for i in range(n - 2, -1, -1):
		c = a[i]
		if c in s:
			w[i] = w[i + 1]
		else:
			w[i] = w[i + 1] + 1
			s.add(c)
	r = []
	for c in q:
		r.append(w[c - 1])
	return '\n'.join(map(str, r))
print(main())


from collections import defaultdict
import sys
(n, m) = [int(i) for i in sys.stdin.readline().split()]
a = [int(i) for i in sys.stdin.readline().split()]
dic = defaultdict(lambda : 0)
b = [0] * (n + 1)
for i in range(n - 1, -1, -1):
	if dic[a[i]] == 0:
		b[i] = b[i + 1] + 1
		dic[a[i]] = 1
	else:
		b[i] = b[i + 1]
for _ in range(m):
	ind = int(sys.stdin.readline())
	print(b[ind - 1])


a = [False] * 100000
(n, m) = map(int, input().split())
x = [0]
s = 0
inp = list(map(int, input().split()))
for i in inp[::-1]:
	if not a[i - 1]:
		s += 1
		a[i - 1] = True
	x.append(s)
print('\n'.join((str(x[-int(input())]) for _ in range(m))))


(n, m) = map(int, input().split())
my_list = list(map(int, input().split()))
my_dict = dict()
current_set = set()
for i in range(n, 0, -1):
	if my_list[i - 1] not in current_set:
		current_set.add(my_list[i - 1])
	my_dict[i] = len(current_set)
for i in range(m):
	print(my_dict[int(input())])


(n, m) = map(int, input().split())
line = [int(x) for x in input().split()]
out = 0
dp = []
a = set()
for i in reversed(line):
	if i not in a:
		out += 1
		a.add(i)
	dp.append(out)
for _ in range(m):
	b = len(line) - int(input())
	print(dp[b])


(n, m) = map(int, input().split())
array = [int(x) for x in input().split()]
array.reverse()
dp = [1] * n
count = {}
count[array[0]] = 1
for i in range(1, n):
	if array[i] not in count:
		dp[i] = dp[i - 1] + 1
		count[array[i]] = 1
	else:
		dp[i] = dp[i - 1]
dp.reverse()
for i in range(m):
	print(dp[int(input()) - 1])


(a, b) = [int(i) for i in input().split(' ')]
s = [int(i) for i in input().split(' ')]
count = {}
compute = [0]
for i in range(a):
	if s[a - i - 1] not in count:
		count[s[a - i - 1]] = 1
		compute.append(compute[i] + 1)
	else:
		compute.append(compute[i])
for i in range(b):
	n = int(input())
	print(compute[a - n + 1])


(n, m) = map(int, input().split())
a_n = input().split()
a_i = [int(input()) - 1 for _ in range(m)]
s = set()
for i in range(n - 1, -1, -1):
	s.add(a_n[i])
	a_n[i] = len(s)
for i in a_i:
	print(a_n[i])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
a.reverse()
aHash = {a[0]: 1}
amounts = [1]
for i in range(1, n):
	if a[i] in aHash:
		amounts.append(amounts[i - 1])
	else:
		aHash[a[i]] = 1
		amounts.append(amounts[i - 1] + 1)
for i in range(0, m):
	l = int(input())
	print(amounts[n - l])


(n, m) = [int(i) for i in input().split()]
nums = [int(i) for i in input().split()]
seen = set()
memo = [1] * n
res = ''
seen.add(nums[n - 1])
for i in range(n - 2, -1, -1):
	if nums[i] not in seen:
		seen.add(nums[i])
		memo[i] = memo[i + 1] + 1
	else:
		memo[i] = memo[i + 1]
for _ in range(m):
	f = int(input())
	res += str(memo[f - 1]) + '\n'
print(res)


(n, m) = [int(i) for i in input().split(' ')]
ai = [int(i) for i in input().split(' ')]
li = []
for i in range(m):
	li.append(int(input()))
s = {ai[n - 1]}
lst = [1] * n
for i in range(n - 2, -1, -1):
	s.add(ai[i])
	lst[i] = len(s)
res = [str(lst[i - 1]) for i in li]
print('\n'.join(res))


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
brr = set()
crr = [0] * n
for i in range(n - 1, -1, -1):
	brr.add(arr[i])
	crr[i] = len(brr)
for i in range(m):
	print(crr[int(input()) - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = set()
suffix = [0] * (n + 1)
for i in range(n - 1, -1, -1):
	f = a[i] not in b
	b.add(a[i])
	suffix[i] = suffix[i + 1] + f
for i in range(m):
	t = int(input())
	print(suffix[t - 1])


(n, m) = map(int, input().split())
line = [int(x) for x in input().split()]
se = []
l = 0
se = {}
dp = []
for _ in range(n):
	a = line.pop()
	try:
		se[a]
	except KeyError:
		se[a] = 1
		l += 1
	dp.append(l)
ans = []
for _ in range(m):
	ans.append(str(dp[n - int(input())]))
print('\n'.join(ans))


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
remains = 0
array_answers = [0] * n
used_numbers = [0] * (10 ** 5 + 1)
for i in range(n - 1, -1, -1):
	if used_numbers[a[i]] == 0:
		remains += 1
		used_numbers[a[i]] = 1
	array_answers[i] = remains
for i in range(m):
	key = int(input())
	print(array_answers[key - 1])


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
p = set()
for i in range(1, n + 1):
	p.add(l[-i])
	l[-i] = str(len(p))
for _ in range(k):
	h = int(input())
	print(l[h - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
s = set()
cnt = 0
for i in range(n - 1, -1, -1):
	if a[i] not in s:
		cnt += 1
		s.add(a[i])
	a[i] = str(cnt)
res = [a[int(input()) - 1] for _ in range(m)]
print('\n'.join(res))


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
dp = [0] * (n + 1)
num = set()
for i in range(n - 1, -1, -1):
	if arr[i] not in num:
		num.add(arr[i])
		dp[i] = dp[i + 1] + 1
	else:
		dp[i] = dp[i + 1]
for _ in range(m):
	l = int(input())
	print(dp[l - 1] - dp[n])


def dp_builder(arr):
	count = [0] * 100001
	a = [0] * (len(arr) + 2)
	i = len(arr)
	while i > 0:
		a[i] = a[i + 1] + (count[arr[i - 1]] == 0)
		count[arr[i - 1]] += 1
		i -= 1
	return a
(n, m) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
res = []
a = dp_builder(a)
for i in range(m):
	res.append(a[int(input())])
print(*res, sep='\n')


(n, m) = [int(i) for i in input().split()]
res = [int(i) for i in input().split()]
a = set([])
a.add(res[n - 1])
dict_ = {}
dict_[str(n - 1)] = 1
if not n == 1:
	for i in range(n - 2, -1, -1):
		if res[i] not in a:
			a.add(res[i])
			dict_[str(i)] = dict_[str(i + 1)] + 1
		else:
			dict_[str(i)] = dict_[str(i + 1)]
ans = [str(dict_[str(int(input()) - 1)]) for _ in range(m)]
print('\n'.join(ans))


(n, m) = map(int, input().split())
a = [int(x) for x in input().split()]
tool = {}
count = [0] * (n + 1)
for i in range(1, n + 1):
	tool[a[-i]] = 1
	count[-i] = len(tool)
for j in range(0, m):
	print(count[int(input())])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
s = set([])
ans = [0] * n
for i in reversed(range(n)):
	if not a[i] in s:
		s.add(a[i])
	ans[i] = len(s)
for i in range(m):
	z = int(input())
	print(ans[z - 1])


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
els = []
for i in range(m):
	els.append(int(input()))
b = set()
aux = [0] * n
cont = 0
for i in range(n - 1, -1, -1):
	if l[i] not in b:
		b.add(l[i])
		cont += 1
	aux[i] = cont
for i in els:
	print(aux[i - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
mArray = []
for j in range(m):
	mArray.append(int(input()))
dp = [0] * (n + 1)
values = [False] * (10 ** 5 + 1)
for i in range(n - 1, -1, -1):
	if values[a[i]]:
		dp[i] = dp[i + 1]
	else:
		dp[i] = dp[i + 1] + 1
	values[a[i]] = True
for j in range(m):
	print(dp[mArray[j] - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
dp = [0] * n
dic = {}
for item in a:
	dic[item] = 0
dp[n - 1] = 1
dic[a[-1]] = 1
for i in range(n - 2, -1, -1):
	if dic[a[i]] == 0:
		dp[i] = dp[i + 1] + 1
		dic[a[i]] = 1
	else:
		dp[i] = dp[i + 1]
for i in range(m):
	print(dp[int(input()) - 1])


(n, m) = map(int, input().split())
a = [int(x) for x in input().split()]
s = set()
ans = [0] * n
for i in range(n - 1, -1, -1):
	s.add(a[i])
	ans[i] = len(s)
for _ in range(m):
	x = int(input())
	x -= 1
	print(ans[x])


(a, b) = map(int, input().rstrip().split())
l = list(map(int, input().rstrip().split()))
c = set()
for i in range(a):
	c.add(l[a - i - 1])
	l[a - i - 1] = len(c)
for _ in [0] * b:
	print(l[int(input()) - 1])


(n, m) = map(int, input().split(' '))
listilla = input().split(' ')
prueba = []
respuesta = [0] * n
res = {}
for e in range(m):
	prueba.append(int(input()))
for l in range(len(listilla) - 1, -1, -1):
	if listilla[l] not in res:
		res[listilla[l]] = 1
		respuesta[n - l - 1] += 1
	if len(listilla) >= 2:
		respuesta[n - l - 1] += respuesta[n - l - 2]
for z in range(0, len(prueba)):
	print(respuesta[len(respuesta) - prueba[z]])


from sys import stdin, stderr

def readInts():
	return map(int, stdin.readline().strip().split())

def print_err(*args, **kwargs):
	print(*args, file=stderr, **kwargs)

def d_a(n, ns):
	out = []
	d = set()
	ns.reverse()
	for v in ns:
		d.add(v)
		out.append(len(d))
	out.reverse()
	return out

def run():
	(n, m) = readInts()
	vs = list(readInts())
	da = d_a(n, vs)
	for _ in range(m):
		(ix,) = readInts()
		print(da[ix - 1])
run()


import math

def get_primes(prime_supr):
	is_prime = [0] * 2 + [1] * prime_supr
	for i in range(2, int(math.sqrt(prime_supr)) + 1):
		if is_prime[i]:
			for j in range(i * i, prime_supr + 1, i):
				is_prime[j] = 0
	return is_prime
get_int = lambda : map(int, input().split())
(n, m) = get_int()
a = list(get_int())
b = []
x = set()
for i in a[::-1]:
	x.add(i)
	b.append(len(x))
ans = []
for i in range(m):
	y = int(input())
	ans.append(b[n - y])
for i in ans:
	print(i)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
ll = [0] * n
d = {}
cnt = 0
for i in range(n - 1, -1, -1):
	if l[i] not in d:
		d[l[i]] = 1
		cnt += 1
	ll[i] = cnt
for i in range(m):
	we = int(input())
	print(ll[we - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
q = []
for i in range(m):
	q.append(int(input()))
h = {}
dp = [0] * n
dp[-1] = 1
h[a[-1]] = 1
for i in range(n - 2, -1, -1):
	if a[i] in h:
		dp[i] = dp[i + 1]
	else:
		h[a[i]] = 1
		dp[i] = dp[i + 1] + 1
for i in q:
	print(dp[i - 1])


(n, m) = map(int, input().split())
s = list(map(int, input().split()))
st = set()
dp = [0 for i in range(n)]
for i in range(n - 1, -1, -1):
	st.add(s[i])
	dp[i] = len(st)
ans = ''
for i in range(m):
	ans += str(dp[int(input()) - 1]) + chr(10)
print(ans)


from sys import *

def input():
	return stdin.readline()
(n, m) = map(int, input().split())
l = [int(i) for i in input().split()]
l = l[::-1]
from collections import *
vis = defaultdict(lambda : False)
c = 0
ans = []
for i in l:
	if not vis[i]:
		c += 1
		ans.append(c)
		vis[i] = True
	else:
		ans.append(c)
ans = ans[::-1]
for _ in range(m):
	x = int(input()) - 1
	print(ans[x])


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
l1 = l[::-1]
sl = 0
setlen = [0] * (n + 1)
setindex = [0] * 100001
i = n
while i > 0:
	if setindex[l1[n - i]] != 1:
		sl += 1
		setindex[l1[n - i]] = 1
	setlen[i] = sl
	i -= 1
for i in range(m):
	a = int(input())
	print(setlen[a])


import sys
input = sys.stdin.buffer.readline
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
c = [0] * n
d = {}
count = 0
for i in range(n - 1, -1, -1):
	if a[i] not in d:
		d[a[i]] = 1
		count += 1
		c[i] = count
	else:
		c[i] = count
for i in range(m):
	q = int(input())
	print(c[q - 1])


k = map(int, input().split())
kk = list(k)
n = kk[0]
m = kk[1]
aux = set()
aa = map(int, input().split())
a = list(aa)
for i in range(n - 1, -1, -1):
	aux.add(a[i])
	a[i] = len(aux)
resp = ''
for i in range(m):
	act = int(input())
	resp += str(a[act - 1]) + '\n'
print(resp)


import sys
(n, m) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
l = [int(i.strip('\n')) for i in sys.stdin.readlines()]
cnt = 0
cnt_l = [0] * len(a)
dist = {}
for i in range(len(a) - 1, -1, -1):
	if not dist.get(a[i]):
		dist[a[i]] = 1
		cnt += 1
		cnt_l[i] = cnt
	else:
		cnt_l[i] = cnt
for i in l:
	print(cnt_l[i - 1])


(n, m) = map(int, input().split())
A = list(map(int, input().split()))
B = [0 for i in range(n)]
b = set()
for i in range(n - 1, -1, -1):
	b.add(A[i])
	B[i] = len(b)
for i in range(m):
	l = int(input())
	print(B[l - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
set_ = set()
for i in range(len(a) - 1, -1, -1):
	set_.add(a[i])
	a[i] = len(set_)
s = ''
for i in range(m):
	l = int(input())
	s += str(a[l - 1]) + '\n'
print(s)


from collections import Counter
(n, m) = map(int, input().split())
dp = [0] * n
array = list(map(int, input().split()))
ct = Counter(array)
ful = len(ct)
dp[0] = ful
for x in range(1, n):
	ct[array[x - 1]] -= 1
	if ct[array[x - 1]] < 1:
		dp[x] = ful - 1
		ful -= 1
	else:
		dp[x] = ful
for _ in range(m):
	print(dp[int(input()) - 1])


(n, m) = tuple(map(int, input().split()))
a = list(map(int, input().split()))
l = []
for k in range(m):
	l.append(int(input()))
seen = set([])
answers = [0]
for i in range(n - 1, -1, -1):
	if a[i] in seen:
		answers.append(answers[-1])
	else:
		seen.add(a[i])
		answers.append(answers[-1] + 1)
for j in l:
	print(answers[n - j + 1])


(n, m) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
s = [0] * (10 ** 5 + 1)
ans = [0] * n
for i in range(n):
	if not s[a[n - 1 - i]]:
		s[a[n - 1 - i]] = 1
		ans[n - 1 - i] = 1
for i in range(n - 1):
	ans[n - 2 - i] += ans[n - 1 - i]
res = []
for i in range(m):
	res.append(str(ans[int(input()) - 1]))
print('\n'.join(res))


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
s = set()
brr = [0] * len(arr)
for i in range(len(arr) - 1, -1, -1):
	s.add(arr[i])
	brr[i] = len(s)
ans = ''
for i in range(m):
	ans += str(brr[int(input()) - 1]) + '\n'
print(ans[:-1])


(num_integers, num_queries) = map(int, input().split())
integers = input().split()
differences = [None] * num_integers
found = set()
for pos in range(num_integers - 1, -1, -1):
	found.add(integers[pos])
	differences[pos] = repr(len(found))
print('\n'.join([str(differences[int(input()) - 1]) for _ in range(num_queries)]))


a = list(map(int, input().split()))
n = a[0]
m = a[1]
a = list(map(int, input().split()))
s = [0] * n
distinct = set()
i = n - 1
for elem in reversed(a):
	distinct.add(elem)
	s[i] = len(distinct)
	i -= 1
for i in range(m):
	x = int(input())
	print(s[x - 1])


(n, m) = tuple(map(int, input().split()))
s = input().split()
d = set()
a = []
for i in reversed(s):
	d.add(i)
	a.append(len(d))
print('\n'.join((str(a[-int(input())]) for _ in range(m))))


(n, q) = map(int, input().split())
l = list(map(int, input().split()))
c = 1
dp = [0] * (n - 1) + [c]
s = set(l[-1:])
for i in range(2, n + 1):
	if l[-i] in s:
		pass
	else:
		s.add(l[-i])
		c += 1
	dp.append(c)
for _ in range(q):
	i = int(input())
	print(dp[-i])


from collections import *
from sys import *
input = stdin.readline
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
s = set()
d = [0] * n
for i in range(n - 1, -1, -1):
	s.add(l[i])
	d[i] = len(s)
for i in range(m):
	x = int(input())
	print(d[x - 1])


(n, m) = map(int, input().split())
A = list(map(int, input().split()))
d = set()
l = [0] * n
for i in range(n - 1, -1, -1):
	d.add(A[i])
	l[i] = len(d)
for i in range(m):
	t = int(input())
	print(l[t - 1])


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
(st, ans) = (set(), [])
for i in range(n - 1, -1, -1):
	st.add(arr[i])
	arr[i] = len(st)
for j in range(m):
	x = int(input()) - 1
	ans.append(arr[x])
print(*ans, sep='\n')


(n, m) = map(int, input().split())
ls = [int(x) for x in input().split()]
lt = [1] * n + [0]
s = set()
for i in range(n - 1, -1, -1):
	if ls[i] in s:
		lt[i] = lt[i + 1]
	else:
		lt[i] = lt[i + 1] + 1
		s.add(ls[i])
for _ in range(m):
	print(lt[int(input()) - 1])


from sys import stdin, stdout
import math
input = stdin.readline

def print(x='', y='', end='\n'):
	if y == '':
		stdout.write(str(x) + end)
	else:
		stdout.write(str(x) + ' ' + str(y) + end)

def solve():
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	d = {l[-1]: 1}
	ans = [0] * n
	ans[n - 1] = 1
	for i in range(n - 2, -1, -1):
		if l[i] in d:
			ans[i] = ans[i + 1]
		else:
			d[l[i]] = 1
			ans[i] = ans[i + 1] + 1
	for i in range(m):
		mi = int(input())
		print(ans[mi - 1])
tt = 1
for __ in range(tt):
	solve()


from collections import defaultdict, Counter
(n, m) = map(int, input().split())
List = [int(x) for x in input().split()]
Dict = Counter(List)
Distinct = len(Dict)
AnsList = [-1] * n
for i in range(n):
	Dict[List[i]] -= 1
	if Dict[List[i]] > 0:
		AnsList[i] = Distinct
	else:
		Distinct -= 1
		AnsList[i] = Distinct + 1
for _ in range(m):
	temp = int(input())
	print(AnsList[temp - 1])


import math
from itertools import *
import random
import calendar
import datetime
import webbrowser
(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
new = set()
result = []
for i in range(n - 1, -1, -1):
	new.add(arr[i])
	result.append(len(new))
result.reverse()
for i in range(m):
	x = int(input()) - 1
	print(result[x])


(n, m) = map(int, input().split())
nl = [int(x) for x in input().split()]
out = 0
dp = []
tset = set()
for i in reversed(nl):
	if i not in tset:
		out += 1
		tset.add(i)
	dp.append(out)
for _ in range(m):
	pos = len(nl) - int(input())
	print(dp[pos])


import sys
from random import choice, randint
inp = sys.stdin.readline
out = sys.stdout.write
flsh = sys.stdout.flush
sys.setrecursionlimit(10 ** 9)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def MI():
	return map(int, inp().strip().split())

def LI():
	return list(map(int, inp().strip().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines().strip()]

def LI_():
	return [int(x) - 1 for x in inp().strip().split()]

def LF():
	return [float(x) for x in inp().strip().split()]

def LS():
	return inp().strip().split()

def I():
	return int(inp().strip())

def F():
	return float(inp().strip())

def S():
	return inp().strip()

def pf(s):
	return out(s + '\n')

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def main():
	(n, m) = MI()
	a = LI()
	dp = [0] * (n + 1)
	d = {a[-1]: 1}
	dp[-1] = 1
	for i in range(n - 2, -1, -1):
		if a[i] not in d:
			d[a[i]] = 1
			dp[i + 1] = dp[i + 2] + 1
		else:
			dp[i + 1] = dp[i + 2]
	for i in range(m):
		l = I()
		pf(str(dp[l]))
main()


(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
l = []
for i in range(m):
	l.append(int(input()))
uniqueSet = set()
mylist = []
a.reverse()
for num in a:
	uniqueSet.add(num)
	mylist.append(len(uniqueSet))
mylist.reverse()
for item in l:
	print(mylist[item - 1])


(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
dic = dict()
b = []
for i in range(n):
	if a[n - i - 1] not in dic:
		dic[a[n - i - 1]] = 1
	else:
		dic[a[n - i - 1]] += 1
	b.append(len(dic))
b.reverse()
for _ in range(m):
	x = int(input())
	print(b[x - 1])


(n, m) = input().split(' ')
array = input().split(' ')
n = int(n)
m = int(m)
array = list(map(int, array))
ind = []
for i in range(m):
	ind.append(int(input()) - 1)
set_a = {'a'}
answers = []
for j in reversed(array):
	set_a.add(j)
	answers.append(len(set_a) - 1)
for q in ind:
	print(answers[n - q - 1])


(n, m) = input().split()
(n, m) = (int(n), int(m))
l = [int(i) for i in input().split()]
d = {i: 0 for i in l}
answer = [1] * n
d[l[-1]] = 1
for i in range(n - 2, -1, -1):
	if d[l[i]] == 0:
		answer[i] = answer[i + 1] + 1
	else:
		answer[i] = answer[i + 1]
	d[l[i]] = 1
for _ in range(m):
	x = int(input())
	print(answer[x - 1])


(n, m) = map(int, input().split())
arr = list(input().split())
index = [int(input()) for _ in range(m)]
nums = [0] * n
dict1 = {}
for i in range(len(arr) - 1, -1, -1):
	if arr[i] not in dict1:
		dict1[arr[i]] = 1
		nums[n - i - 1] += 1
	if len(nums) >= 2:
		nums[n - i - 1] += nums[n - i - 2]
for i in range(0, len(index)):
	print(nums[len(nums) - index[i]])


import math
import sys, collections
from sys import stdin, stdout

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()

def input():
	return sys.stdin.readline().strip()

def file():
	sys.stdin = open('input.py', 'r')
	sys.stdout = open('output.py', 'w')

def is_subsequence(x, y):
	x = list(x)
	for letter in y:
		if x and x[0] == letter:
			x.pop(0)
	return not x

def sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, mt.ceil(mt.sqrt(MAXN))):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def getFactorization(x):
	ret = list()
	while x != 1:
		ret.append(spf[x])
		x = x // spf[x]
	return ret

def getFloor(A, x):
	(left, right) = (0, len(A) - 1)
	(ind, floor) = (-1, -1)
	while left <= right:
		mid = (left + right) // 2
		if x < A[mid]:
			right = mid - 1
		else:
			floor = A[mid]
			ind = mid
			left = mid + 1
	return ind

def check(st):
	n = len(st)
	digitSum = 0
	for i in range(0, n):
		digitSum = digitSum + int(st[i])
	return digitSum % 9 == 0

def isPowerOfTwo(n):
	if n == 0:
		return False
	while n != 1:
		if n % 2 != 0:
			return False
		n = n // 2
	return True

def kitte(n):
	c = 0
	while n != 0:
		n = n // 2
		c += 1
	return c
mod = 10 ** 9 + 7

def main():
	(n, m) = get_ints()
	l = get_array()
	d = collections.defaultdict(int)
	l.reverse()
	temp = []
	c = 1
	for i in l:
		if d[i] == 0:
			temp.append(c)
			c += 1
			d[i] += 1
		else:
			temp.append(c - 1)
	temp.reverse()
	for i in range(m):
		print(temp[int(input()) - 1])
main()


from collections import defaultdict
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
l = []
s = [1]
d = defaultdict(int)
for i in range(m):
	l.append(int(input()))
d[a[-1]] += 1
a = a[-2::-1]
for i in range(len(a)):
	if d[a[i]] == 0:
		s.append(s[-1] + 1)
	else:
		s.append(s[-1])
	d[a[i]] += 1
s = s[::-1]
for i in l:
	print(s[i - 1])


import sys
import collections
import math
import functools
import itertools
import bisect
import operator
import heapq
import random
true = True
false = False
null = None
tcid = 0
tcmax = 99999999

def compute(val, func):
	return func(val)

def seq(lo, hi, step=1):
	return range(lo, hi + 1, step)

def sround(val, nd):
	return f'{val:.{nd}f}'

def ceil(a, b):
	ans = a // b
	if a % b != 0:
		ans += 1
	return ans

def perr(*args, **kwargs):
	print(*args, file=sys.stderr, **kwargs)

def line():
	ln = sys.stdin.readline().strip()
	if ln == '':
		sys.exit()
	return ln

def lines(n):
	return [line() for i in range(n)]

def split(ln=None):
	return (ln or line()).split()

def num(str=None):
	str = str or line()
	return float(str) if '.' in str else int(str)

def nums(o=None):
	if o is not None:
		if isinstance(o, int):
			o = lines(o)
		elif isinstance(o, str):
			o = split(o)
	return list(map(num, o or split()))

def mainloop(tcid=1):
	(n, m) = nums()
	a = nums()
	ans = []
	ss = set()
	a.reverse()
	for aa in a:
		ss.add(aa)
		ans.append(len(ss))
	ans.reverse()
	for l in nums(m):
		print(ans[l - 1])
while tcid < tcmax:
	tcid += 1
	mainloop(tcid)


(n, m) = [int(i) for i in input().split(' ')]
array1 = [int(i) for i in input().split(' ')]
array2 = []
for i in range(m):
	array2.append(int(input()))
array3 = []
check = set()
for i in range(n):
	check.add(array1[-i - 1])
	array3.append(len(check))
for i in array2:
	print(array3[-i])


(n, m) = [int(s) for s in input().split(' ')]
nums = [int(s) for s in input().split(' ')]
dp = [0] * n
dp[-1] = 1
occurences = {nums[-1]: 1}
for i in range(len(nums) - 2, -1, -1):
	try:
		if occurences[nums[i]] == 1:
			dp[i] = dp[i + 1]
	except KeyError:
		occurences[nums[i]] = 1
		dp[i] = dp[i + 1] + 1
for i in range(m):
	l = int(input())
	print(dp[l - 1])


input_str = input()
n = int(input_str.split(' ')[0])
m = int(input_str.split(' ')[1])
input_list = input().split(' ')
input_list.reverse()
num_dict = {}
tmp_dict = {}
tmp_list = []
count = 0
for (my_index, i) in enumerate(input_list):
	if tmp_dict.get(i) is None:
		tmp_dict.update({i: 0})
		count += 1
	num_dict.update({my_index: count})
len_list = len(input_list)
for _ in range(m):
	ai = int(input())
	print(num_dict[len_list - ai])


(n, m) = map(int, input().split())
listNum = list(map(int, input().split()))
listResult = [1] * n
setNum = set()
setNum.add(listNum[n - 1])
for i in range(n - 2, -1, -1):
	listResult[i] = listResult[i + 1]
	if listNum[i] not in setNum:
		listResult[i] += 1
		setNum.add(listNum[i])
finalResult = ''
for _ in range(m):
	finalResult += str(listResult[int(input()) - 1]) + '\n'
print(finalResult)


lst = input().split()
(n, m) = (int(lst[0]), int(lst[1]))
a = input().split()
for i in range(len(a)):
	a[i] = int(a[i])
p = [0] * 100001
dp = [0] * n
for i in range(n - 1, -1, -1):
	if i == n - 1:
		dp[i] = 1
		p[a[i]] = 1
	elif p[a[i]] == 0:
		dp[i] = dp[i + 1] + 1
		p[a[i]] = 1
	else:
		dp[i] = dp[i + 1]
while m > 0:
	m -= 1
	l = int(input())
	print(dp[l - 1])


(n, m) = [int(x) for x in input().strip().split()]
a = [int(x) for x in input().strip().split()]
dic = {}
dp = [None for i in range(n)]
dp[n - 1] = 1
dic[a[n - 1]] = 1
for i in range(n - 2, -1, -1):
	if a[i] not in dic:
		dp[i] = dp[i + 1] + 1
		dic[a[i]] = 1
	else:
		dp[i] = dp[i + 1]
for i in range(m):
	u = int(input())
	print(dp[u - 1])


N = 10 ** 5 + 10

def solve():
	(n, m) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	a.reverse()
	tem = [False] * N
	ans = [0] * N
	for i in range(n):
		if not tem[a[i]]:
			ans[i] += 1
			tem[a[i]] = True
		ans[i + 1] = ans[i]
	for i in range(m):
		l = int(input())
		l = n - l
		print(ans[l])
solve()


(n, m) = map(int, input().split())
s = set()
l = [*map(int, input().split())]
res = [0]
for e in l[::-1]:
	s.add(e)
	res.append(len(s))
res.reverse()
for _ in range(m):
	i = int(input())
	print(res[i - 1])


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
import sys
input = sys.stdin.readline
scan_int = lambda : int(input())
scan_string = lambda : input().rstrip()
read_list = lambda : list(read())
read = lambda : map(int, input().split())
read_float = lambda : map(float, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def is_integer(n):
	return math.ceil(n) == math.floor(n)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def next_prime(n, primes):
	while primes[n] != True:
		n += 1
	return n
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(beauty, s, n, count):
	pass
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations
import math
import bisect as bis
import random
import sys
import collections as collect

def solve():
	(n, m) = read()
	a = read_list()
	track_element = {}
	track_index = {}
	c = 0
	for i in range(n - 1, -1, -1):
		if track_element.get(a[i]) == None:
			c += 1
			track_index[i + 1] = c
			track_element[a[i]] = 1
		else:
			track_index[i + 1] = c
	for i in range(m):
		l = scan_int()
		print(track_index[l])
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for i in range(1):
	solve()


from sys import *
input = stdin.readline
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
p = set()
for i in range(1, n + 1):
	p.add(l[-i])
	l[-i] = str(len(p))
for _ in range(k):
	h = int(input())
	print(l[h - 1])


def sort_and_get_len(list):
	list.sort()
	temp = list[0]
	count = 1
	for x in list:
		if temp != x:
			count += 1
			temp = x
	return count
line1 = input()
(n, m) = [int(x) for x in line1.split()]
line2 = input()
code = [x for x in line2.split()]
times = [1]
temp = code[-1]
code_copy = code[:-1]
count = 1
dealed_set = set()
dealed_set.add(temp)
for (num, i) in enumerate(code_copy[::-1]):
	if i not in dealed_set:
		count += 1
		temp = i
		dealed_set.add(i)
	times.append(count)
times.reverse()
for i in range(m):
	index = int(input())
	print(times[index - 1])


def main():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	(results, equals) = ([0] * (n + 1), {})
	for i in range(1, len(a) + 1):
		a_i = a[-i]
		eq_count = equals.get(a_i, 0)
		equals[a_i] = eq_count + 1
		results[-(i + 1)] = results[-i] + (0 if eq_count else 1)
	for _ in range(m):
		print(results[int(input()) - 1])
main()


(n, m) = map(int, input().split())
line = input().split()
a = []
b = set()
for i in range(n):
	b.add(line[n - i - 1])
	a.append(len(b))
for i in range(m):
	print(a[n - int(input())])


a = list(map(int, input().strip(' ').split(' ')))
s = list(map(int, input().strip(' ').split(' ')))
s.insert(0, 'o')
haspmap = set()
count = 1
for i in range(a[0], 0, -1):
	if s[i] in haspmap:
		s[i] = count - 1
	else:
		haspmap.add(s[i])
		s[i] = count
		count += 1
for i in range(0, a[1]):
	sd = int(input())
	print(s[sd])


(n, m) = list(map(int, input().split(' ')))
numbers = list(map(int, input().split(' ')))
seen = [0 for _ in range(max(numbers) + 1)]
acum = [0 for _ in range(n + 1)]
acum[n - 1] = 1
seen[numbers[n - 1]] = True
for i in range(n - 2, -1, -1):
	cur = numbers[i]
	acum[i] = acum[i + 1]
	if not seen[cur]:
		seen[cur] = True
		acum[i] += 1
for i in range(m):
	q = int(input())
	print(acum[q - 1])


import sys
import copy
listm = []
visited = []
for i in range(100002):
	visited.append(0)
checklist = []
for i in range(100002):
	checklist.append(0)
(n, m) = map(int, sys.stdin.readline().split())
listi = input().split(' ')
for i in range(0, m):
	listm.append(input())
count = 0
i = n - 1
while i >= 0:
	value = int(listi[i])
	if not checklist[value]:
		count += 1
	checklist[value] = 1
	visited[i] = count
	i -= 1
x = 1
while m > 0:
	for number in listm:
		print(visited[int(number) - 1])
		m -= 1


(n, m) = [int(i) for i in input().split()]
res = input().split()
a = set([])
dict_ = {}
c = 0
for i in range(n - 1, -1, -1):
	a.add(res[i])
	dict_[str(i + 1)] = len(a)
print('\n'.join([str(dict_[str(int(input()))]) for i in range(m)]))


import sys
import math
(n, m) = [int(x) for x in sys.stdin.readline().split()]
an = [int(x) for x in sys.stdin.readline().split()]
k = [0] * n
kj = [0] * 100001
k[n - 1] = 1
kj[an[n - 1]] = 1
for i in range(n - 2, -1, -1):
	z = 0
	if kj[an[i]] == 0:
		z = 1
	kj[an[i]] = 1
	k[i] = k[i + 1] + z
for i in range(m):
	d = int(sys.stdin.readline())
	print(k[d - 1])


import sys
(n, m) = map(int, sys.stdin.readline().split())
l = list(map(int, sys.stdin.readline().split()))
arr = []
s = set()
k = 0
for i in range(n - 1, -1, -1):
	if l[i] not in s:
		k += 1
		s.add(l[i])
	arr.append(k)
for _ in range(m):
	c = int(sys.stdin.readline())
	print(arr[n - c])


__author__ = 'Juan Barros'

def solve(n, a):
	values = {a[n - 1]}
	dp = [0] * (n + 1)
	dp[-1] = 1
	for i in range(n - 1, -1, -1):
		if a[i - 1] in values:
			dp[i] = dp[i + 1]
		else:
			values.add(a[i - 1])
			dp[i] = dp[i + 1] + 1
	return dp
(n, m) = list(map(int, input().split()))
a = [int(element) for element in input().split(' ')]
query = []
for i in range(m):
	query.append(int(input()))
dp = solve(n, a)
for i in range(m):
	print(dp[query[i]])


def main():
	nm = list(map(int, input().split()))
	n = nm[0]
	k = nm[1]
	a = list(map(int, input().split()))
	dict = {}
	lengths = [0] * n
	for i in range(n - 1, -1, -1):
		if i == n - 1:
			dict[a[i]] = 1
			lengths[i] = 1
		elif a[i] in dict:
			lengths[i] = lengths[i + 1]
			dict[a[i]] = 1
		else:
			lengths[i] = 1 + lengths[i + 1]
			dict[a[i]] = 1
	for i in range(k):
		poz = int(input())
		print(lengths[poz - 1])
main()


(n, m) = map(int, input().split())
d = list(map(int, input().split()))
ans = (n + 1) * [0]
cnt = 100001 * [0]
for i in range(n - 1, -1, -1):
	if cnt[d[i]] == 0:
		ans[i] = ans[i + 1] + 1
	else:
		ans[i] = ans[i + 1]
	cnt[d[i]] = cnt[d[i]] + 1
for i in range(m):
	l = int(input())
	print(ans[l - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
o = 0
dp = []
l = set()
for i in reversed(a):
	if i not in l:
		o += 1
		l.add(i)
	dp.append(o)
ans = []
for _ in range(m):
	k = len(a) - int(input())
	ans.append(dp[k])
print('\n'.join(map(str, ans)))


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
a.insert(0, 0)
seen = []
cnt = []
for i in range(100005):
	seen.append(False)
	cnt.append(0)
for i in range(n, 0, -1):
	if not seen[a[i]]:
		seen[a[i]] = True
		cnt[i] = 1 + cnt[i + 1]
	else:
		cnt[i] = cnt[i + 1]
ans = []
for i in range(m):
	l = int(input())
	ans.append(cnt[l])
for each in ans:
	print(each)


(n, m) = [int(x) for x in input().split()]
array = [int(x) for x in input().split()]
dis = ['1'] * n
s = set()
for i in range(n - 1, -1, -1):
	s.add(array[i])
	dis[i] = str(len(s))
print('\n'.join([dis[int(input()) - 1] for _ in range(m)]))


import sys
it = iter(sys.stdin.read().splitlines())
(n, m) = [int(x) for x in next(it).split()]
arr = next(it).split()
d = {}
c = [0 for i in range(n + 1)]
for i in range(n):
	d[arr[i]] = 0
for i in range(n)[::-1]:
	d[arr[i]] = d[arr[i]] + 1
	if d[arr[i]] == 1:
		c[i] = c[i + 1] + 1
	else:
		c[i] = c[i + 1]
for i in range(m):
	n = int(next(it))
	print(c[n - 1])


(n, m) = map(int, input().split())
seq = list(map(int, input().split()))
out = 0
dp = []
tset = set()
for i in range(n - 1, -1, -1):
	if seq[i] not in tset:
		tset.add(seq[i])
		out += 1
	dp.append(out)
dp.reverse()
for i in range(m):
	print(dp[int(input()) - 1])


(n, m) = map(int, input().split())
lsn = list(map(int, input().split()))
d = {}
dr = {}
k = 0
lsm = []
for v in range(m):
	lsm.append(int(input()))
mn = min(lsm)
for i in range(n, mn - 1, -1):
	if lsn[i - 1] not in dr:
		k = k + 1
		d[i] = k
		dr[lsn[i - 1]] = 1
	else:
		d[i] = k
for z in lsm:
	print(d[z])


def codeforces():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	l = [int(input()) for _ in range(m)]
	st = set()
	dct = {}
	dct[n - 1] = 1
	st.add(a[-1])
	for i in range(n - 2, -1, -1):
		if a[i] not in st:
			dct[i] = dct[i + 1] + 1
			st.add(a[i])
		else:
			dct[i] = dct[i + 1]
	res = [str(dct[l[i] - 1]) for i in range(m)]
	return '\n'.join(res)
print(codeforces())


from collections import defaultdict
(n, k) = map(int, input().split())
lst = list(map(int, input().split()))
dic = defaultdict(int)
for i in lst:
	dic[i] += 1
count = [len(dic)]
dic[lst[0]] -= 1
if dic[lst[0]] > 0:
	current = len(dic)
else:
	current = len(dic) - 1
for i in range(1, n):
	if dic[lst[i]] > 1:
		count.append(current)
		dic[lst[i]] -= 1
	else:
		count.append(current)
		current -= 1
for i in range(k):
	a = int(input())
	print(count[a - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
s = set()
b = [0] * len(a)
for i in range(len(a) - 1, -1, -1):
	if a[i] not in s:
		s.add(a[i])
	b[i] = len(s)
for i in range(m):
	print(b[int(input()) - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
ls = set()
result = {}
show = []
for i in range(n):
	ls.add(a[n - i - 1])
	result[n - i] = len(ls)
for i in range(m):
	l = int(input())
	show.append(result[l])
for i in show:
	print(i)


(n, m) = map(int, input().split())
A = [int(x) for x in input().split()]
cnt = [0] * (max(A) + 1)
ans = [0] * (n + 1)
for i in range(n - 1, -1, -1):
	if cnt[A[i]] == 0:
		ans[i] = ans[i + 1] + 1
		cnt[A[i]] = 1
	else:
		ans[i] = ans[i + 1]
for i in range(m):
	print(ans[int(input()) - 1])


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
s = set()
l1 = [0] * 100002
for i in range(n):
	s.add(l[n - i - 1])
	l1[n - i] = len(s)
for i in range(m):
	print(l1[int(input())])


def sereja_suffix(arr, l, n, m):
	dp = [0] * n
	dp[-1] = 1
	s = set()
	s.add(arr[-1])
	for i in range(n - 2, -1, -1):
		dp[i] += dp[i + 1]
		if arr[i] not in s:
			s.add(arr[i])
			dp[i] += 1
	for i in l:
		print(dp[i - 1])
(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
l = []
for i in range(m):
	l.append(int(input()))
sereja_suffix(arr, l, n, m)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
l = [int(input()) for i in range(m)]
invalid = -1
ans = [invalid] * n
s = set()
for i in range(n - 1, -1, -1):
	s.add(a[i])
	ans[i] = len(s)
for i in range(m):
	out = ans[l[i] - 1]
	if out != invalid:
		print(ans[l[i] - 1])


s = input()
(n, m) = (int(s.split()[0]), int(s.split()[1]))
a = [int(x) for x in input().split()]
s = [0 for i in range(0, n)]
_set = set()
for i in range(n - 1, -1, -1):
	_set.add(a[i])
	s[i] = len(_set)
l = []
for i in range(0, m):
	l.append(int(input()))
for i in range(0, m):
	print(s[l[i] - 1])


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
values = []
while m > 0:
	m -= 1
	a = int(input())
	values.append(a)
arr = arr[::-1]
res = set()
val = []
for i in arr:
	res.add(i)
	val.append(len(res))
val = val[::-1]
for i in values:
	print(val[i - 1])


(n, m) = map(int, input().split())
l = [int(x) for x in input().split()]
l.insert(0, 0)
dist = [0] * (n + 7)
g = set()
for i in range(n, 0, -1):
	g.add(l[i])
	dist[i] = len(g)
for i in range(m):
	t = int(input())
	print(dist[t])


from collections import Counter
(n, m) = map(int, input().split())
array = list(map(int, input().split()))
queries = []
for i in range(m):
	l = int(input())
	queries.append(l)
s_queries = sorted(set(queries))
j = 0
ans = {}
c = Counter(array)
for q in s_queries:
	while j < q - 1:
		c[array[j]] -= 1
		if c[array[j]] <= 0:
			del c[array[j]]
		j += 1
	ans[q] = len(c)
for q in queries:
	print(ans[q])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
d = {a[-1]: 1}
l = [1]
for x in a[n - 2::-1]:
	l += [l[-1]]
	if d.get(x, 0) == 0:
		l[-1] += 1
		d[x] = 1
l = l[::-1]
if n == 1:
	l = [1]
ans = []
for _ in range(m):
	ans += [str(l[int(input()) - 1])]
print('\n'.join(ans))


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
temp = []
for _ in range(n):
	temp += [0]
udict = {}
count = 0
for i in range(n - 1, -1, -1):
	if arr[i] not in udict:
		udict[arr[i]] = 1
		count += 1
	temp[i] = count
for _ in range(m):
	print(temp[int(input()) - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
q = []
for i in range(m):
	q.append([int(input()) - 1, i])
q.sort()
res = [0] * m
s = set()
now = n - 1
loc = m - 1
while now >= 0 and loc >= 0:
	s.add(a[now])
	if now == q[loc][0]:
		while loc >= 0 and now == q[loc][0]:
			res[q[loc][1]] = len(s)
			loc -= 1
	now -= 1
print('\n'.join(map(str, res)))


from sys import stdin, stdout
(n, m) = map(int, stdin.readline().split())
a = list(map(int, stdin.readline().split()))
c = [0] * n
c[n - 1] = 1
s = [False] * 100001
s[a[n - 1]] = True
for i in range(1, n):
	if s[a[n - i - 1]]:
		c[n - i - 1] = c[n - i]
	else:
		c[n - i - 1] = c[n - i] + 1
		s[a[n - i - 1]] = True
stdout.write('\n'.join((str(c[l - 1]) for l in map(int, stdin.read(None).split()))))


(n, m) = map(int, input().split())
arr = {}
l = [int(x) for x in input().split()]
for i in range(1, n + 1):
	arr[i] = l[i - 1]
d = {}
s = set()
for i in range(n, 0, -1):
	s.add(arr[i])
	d[i] = len(s)
for t in range(m):
	l = int(input())
	print(d[l])


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
s = set()
dis = [0 for i in range(n)]
count = 0
for i in range(n - 1, -1, -1):
	if arr[i] not in s:
		count += 1
		s.add(arr[i])
	dis[i] = count
l = []
for _ in range(m):
	li = int(input())
	print(dis[li - 1])


f = lambda : map(int, input().split())
(n, m) = f()
x = list(f())
(s, cnt) = (set(), 0)
d = [0] * (n + 5)
for i in range(n - 1, -1, -1):
	s.add(x[i])
	d[i] = len(s)
print('\n'.join((str(d[int(input()) - 1]) for i in range(m))))


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
s = set()
l1 = [0] * n
for i in range(n - 1, -1, -1):
	s.add(l[i])
	l1[i] = len(s)
for i in range(0, m):
	q = int(input())
	print(l1[q - 1])


(n, m) = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
C = [0] * n
added_list = [False] * (100000 + 1)
C[n - 1] = 1
added_list[A[n - 1]] = True
for i in range(n - 2, -1, -1):
	if not added_list[A[i]]:
		C[i] = C[i + 1] + 1
		added_list[A[i]] = True
	else:
		C[i] = C[i + 1]
for i in range(m):
	print(C[int(input()) - 1])


(n, m) = map(int, input().split())
list1 = list(map(int, input().split()))
(list2, result) = ([], [0 for _ in range(n)])
for i in range(m):
	list2.append(int(input()))
tempdict = {}
temp = 0
nums = n - 1
for i in list1[::-1]:
	if tempdict.get(i, 0) == 0:
		tempdict[i] = 1
		temp += 1
	result[nums] = temp
	nums -= 1
for i in list2:
	print(result[i - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
q = list()
for _ in range(m):
	q.append(int(input()))
s = set()
ans = [1 for i in range(n)]
k = 0
for i in range(n - 1, min(q) - 2, -1):
	if a[i] not in s:
		k += 1
		s.add(a[i])
	ans[i] = k
for i in q:
	print(ans[i - 1])


(n, m) = map(int, input().split())
a = [int(x) for x in input().split()]
a.insert(0, 0)
ans = [1]
set1 = set([a[n]])
for i in range(n - 1):
	if a[n - i - 1] not in set1:
		set1.add(a[n - i - 1])
		ans.append(ans[-1] + 1)
	else:
		ans.append(ans[-1])
ans.reverse()
for i in range(m):
	print(ans[int(input()) - 1])


__author__ = 'sm'

def readln():
	return list(map(int, input().split()))
(n, m) = readln()
data = readln()
dp = [0] * n
dp[n - 1] = 1
cache = set()
cache.add(data[n - 1])
i = n - 2
while i >= 0:
	if data[i] in cache:
		dp[i] = dp[i + 1]
	else:
		dp[i] = dp[i + 1] + 1
		cache.add(data[i])
	i -= 1
ans = []
for i in range(m):
	idx = readln()[0]
	ans.append(str(dp[idx - 1]))
print('\n'.join(ans))


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
z = set()
l = []
for i in range(n - 1, -1, -1):
	z.add(a[i])
	l.append(str(len(z)))
print('\n'.join([l[n - int(input())] for _ in range(m)]))


(n, m) = [int(x) for x in input().split()]
a = list(map(int, input().split()))
s = set()
t = []
for i in range(n - 1, -1, -1):
	s.add(a[i])
	t.append(len(s))
o = []
for i in range(m):
	x = int(input())
	o.append(str(t[-x]))
print('\n'.join(o))


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
dp = [0] * n
hashmap = dict()
dp[n - 1] = 1
hashmap[a[n - 1]] = True
for i in reversed(range(n - 1)):
	if a[i] in hashmap:
		dp[i] = dp[i + 1]
	else:
		dp[i] = 1 + dp[i + 1]
	hashmap[a[i]] = True
for i in range(m):
	print(dp[int(input()) - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
p = [0]
k = [0] * (10 ** 5 + 3)
for i in range(1, n + 1):
	if k[a[-i]] == 0:
		k[a[-i]] = 1
		p.append(p[i - 1] + 1)
	else:
		p.append(p[i - 1])
for i in range(m):
	print(p[-int(input())])


(n, m) = [int(i) for i in input().split()]
sequence = list(map(int, input().split()))
l_list = [int(input()) - 1 for _ in range(m)]
max_num = max(sequence)
f = [0] * (max_num + 1)
k = 0
d = [0] * len(sequence)
for i in range(len(sequence) - 1, -1, -1):
	index = sequence[i]
	if f[index] == 0:
		f[index] = 1
		k += 1
	d[i] = k
for i in l_list:
	print(d[i])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
a.reverse()
aHash = {}
amounts = {}
for i in range(0, n):
	if not a[i] in aHash:
		aHash[a[i]] = 1
	amounts[n - i] = len(aHash)
for i in range(0, m):
	l = int(input())
	print(amounts[l])


(n, m) = map(int, input().split())
array = list(map(int, input().split()))
sets = set()
red = [0] * n
for i in range(n - 1, -1, -1):
	sets.add(array[i])
	red[i] = len(sets)
for i in range(m):
	print(red[int(input()) - 1])


(n, m) = map(int, input().split())
a = input().split()
nums = set()
distinctCount = [0] * n
indices = [int(input()) - 1 for _ in range(m)]
for i in range(n - 1, -1, -1):
	nums.add(a[i])
	distinctCount[i] = len(nums)
for i in indices:
	print(distinctCount[i])


def prog():
	from sys import stdin
	(n, m) = map(int, stdin.readline().split())
	lst = list(map(int, input().split()))
	(d, a) = ({}, 0)
	for (i, x) in enumerate(lst):
		if d.get(x) == None:
			d[x] = 0
			a += 1
		d[x] += 1
	res = {0: a}
	for i in range(1, n):
		x = lst[i - 1]
		d[x] -= 1
		if d[x] == 0:
			a -= 1
		res[i] = a
	for i in range(m):
		x = int(stdin.readline())
		print(res[x - 1])
prog()


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
j = n - 2
ans = [1] * n
neww = {a[-1]}
while j >= 0:
	neww.add(a[j])
	ans[j] = len(neww)
	j -= 1
for i in range(m):
	chk = int(input())
	print(ans[chk - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
suffix = [0] * n
suffix[-1] = 1
s = set()
s.add(a[-1])
for i in range(n - 2, -1, -1):
	if a[i] not in s:
		suffix[i] = suffix[i + 1] + 1
	else:
		suffix[i] = suffix[i + 1]
	s.add(a[i])
for _ in range(m):
	print(suffix[int(input()) - 1])


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
ans = [0] * n
count = 0
d = {}
for i in range(n - 1, -1, -1):
	if l[i] not in d:
		count += 1
		d[l[i]] = 1
	ans[i] = count
for i in range(m):
	print(ans[int(input()) - 1])


from collections import deque
(n, m) = map(int, input().split())
s = list(map(int, input().split()))
ans = deque([0])
dif = [False for i in range(10 ** 5 + 1)]
for i in range(n - 1, -1, -1):
	if not dif[s[i]]:
		ans.appendleft(ans[0] + 1)
		dif[s[i]] = True
	else:
		ans.appendleft(ans[0])
print('\n'.join([str(ans[int(input()) - 1]) for _ in range(m)]))


(n, m) = (int(x) for x in input().split())
l = [int(x) for x in input().split()]
d = {}
nr = 0
for x in l:
	if x not in d:
		d[x] = 1
		nr += 1
	else:
		d[x] += 1
sol = []
for x in l:
	sol.append(nr)
	d[x] -= 1
	if d[x] == 0:
		nr -= 1
for i in range(m):
	k = input()
	k = int(k)
	print(sol[k - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
dist = [0] * n
d = {}
for i in range(n - 1, -1, -1):
	if a[i] not in d:
		d[a[i]] = 1
	dist[i] = len(d)
for i in range(m):
	x = int(input())
	print(dist[x - 1])


(n, m) = map(int, input().split())
l = [int(s) for s in input().split()]
dp = [0] * n
s = set()
for i in range(n - 1, -1, -1):
	s.add(l[i])
	dp[i] = len(s)
while m > 0:
	t = int(input())
	print(dp[t - 1])
	m -= 1


import collections
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
d = collections.Counter(a)
v = {}
for i in range(n):
	v[i + 1] = len(d)
	d[a[i]] -= 1
	if d[a[i]] == 0:
		del d[a[i]]
for i in range(m):
	b = int(input())
	print(v[b])


from collections import defaultdict
(n, m) = map(int, input().split())
l = []
a = list(map(int, input().split()))
hash_table = defaultdict(lambda : 0)
for i in range(m):
	temp = int(input())
	l.append(temp)
res = [0] * 1000000
res[n + 1] = 0
i = n
for x in reversed(a):
	hash_table[x] += 1
	if hash_table[x] == 1:
		res[i] = res[i + 1] + 1
	else:
		res[i] = res[i + 1]
	i -= 1
for x in l:
	print(res[x])


import sys
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
mx = int(100000.0)
number = [0 for _ in range(mx + 1)]
count = [0 for _ in range(n)]
c = 0
for i in range(n - 1, -1, -1):
	num = a[i]
	if number[num] == 0:
		number[num] = 1
		c += 1
	count[i] = c
for i in range(m):
	sys.stdout.write('{}\n'.format(count[int(sys.stdin.readline()) - 1]))


(n, m) = map(int, input().split())
A = [int(s) for s in input().split()]
uniques = set()
counts = [0] * n
for i in range(n):
	uniques.add(A[n - 1 - i])
	counts[n - 1 - i] = len(uniques)
for i in range(m):
	l = int(input())
	print(counts[l - 1])


(nm, ls, s) = (list(map(int, input().split())), list(map(int, input().split(' '))), set())
ls2 = [-1 for _ in range(nm[0])]
for i in range(nm[0] - 1, -1, -1):
	s.add(ls[i])
	ls2[i] = len(s)
for _ in range(nm[1]):
	print(ls2[int(input()) - 1])


(n, m) = map(int, input().split())
seq = list(map(int, input().split()))
saida = [0] * n
s = set()
cont = 0
for e in range(len(seq) - 1, -1, -1):
	if seq[e] not in s:
		s.add(seq[e])
		cont += 1
	saida[e] = cont
for c in range(m):
	print(saida[int(input()) - 1])


(n, m) = map(int, input().split())
ar = list(map(int, input().split()))
a = set()
l = [0] * n
for i in range(n - 1, -1, -1):
	a.add(ar[i])
	l[i] = len(a)
for i in range(m):
	lx = int(input())
	print(l[lx - 1])


from sys import stdin
(n, m) = map(int, stdin.readline().strip().split())
a = list(map(int, stdin.readline().split()))
s = set()
b = [0] * n
for i in range(n - 1, -1, -1):
	s.add(a[i])
	b[i] = len(s)
for i in range(m):
	l = int(stdin.readline())
	print(b[l - 1])


def main():
	(n, m) = [int(c) for c in input().split()]
	A = [int(c) for c in input().split()]
	L = [int(input()) for _ in range(m)]
	acc = [0]
	_set = set()
	for i in range(n - 1, -1, -1):
		if A[i] not in _set:
			acc.append(acc[-1] + 1)
			_set.add(A[i])
		else:
			acc.append(acc[-1])
	acc = acc[::-1]
	acc.pop()
	for query in L:
		print(acc[query - 1])
main()


from sys import stdin
input = stdin.readline

def main():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	suff = [0] * n
	suff[n - 1] = 1
	all = set()
	all.add(a[n - 1])
	for i in range(n - 2, -1, -1):
		if a[i] in all:
			suff[i] = suff[i + 1]
		else:
			suff[i] = suff[i + 1] + 1
			all.add(a[i])
	for q in range(m):
		l = int(input())
		print(suff[l - 1])
main()


input = __import__('sys').stdin.readline
(n, m) = map(int, input().split())
lis = list(map(int, input().split()))
has = [0] * 100005
ans = [0] * n
ans[n - 1] = 1
has[lis[n - 1]] = 1
for i in range(n - 2, -1, -1):
	if has[lis[i]] == 0:
		ans[i] = ans[i + 1] + 1
		has[lis[i]] = 1
	else:
		ans[i] = ans[i + 1]
for i in range(m):
	q = int(input())
	print(ans[q - 1])


(n, m) = map(int, input().split())
a = [int(i) for i in input().split()]
counts = {}
for num in a:
	if num not in counts.keys():
		counts[num] = 0
	counts[num] += 1
dp = [len(counts.keys())] * n
for i in range(1, n):
	dp[i] = dp[i - 1] - int(counts[a[i - 1]] == 1)
	counts[a[i - 1]] -= 1
results = []
for i in range(m):
	l = int(input())
	results.append(dp[l - 1])
for result in results:
	print(result)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
c = set()
p = [0] * n
o = 0
for i in range(n - 1, -1, -1):
	c.add(l[i])
	p[i] = len(c)
for i in range(m):
	a = int(input())
	print(p[a - 1])


(n, m) = map(int, input().split())
v = [int(i) for i in input().split()]
z = 10 ** 5 + 1
cnt = [0] * z
ans = [0] * n
r = 0
for i in range(n - 1, -1, -1):
	cnt[v[i]] += 1
	if cnt[v[i]] == 1:
		r += 1
	ans[i] = r
res = [0] * m
for i in range(m):
	q = int(input())
	res[i] = str(ans[q - 1])
print('\n'.join(res))


(n, m) = map(int, input().split())
arr = []
for i in map(int, input().split()):
	arr.append(i)
arrM = [int(input()) for i in range(m)]
Set = set()
count = 0
counter = [0] * n
for j in range(n - 1, -1, -1):
	if arr[j] not in Set:
		Set.add(arr[j])
		count += 1
	counter[j] = count
for i in arrM:
	print(counter[i - 1])


(n, m) = list(map(int, input().split()))
values = list(map(int, input().split()))
temp = {}
temp2 = set()
for i in range(n - 1, -1, -1):
	temp2.add(values[i])
	temp[i] = len(temp2)
result = []
for i in range(m):
	v = int(input())
	result.append(str(temp[v - 1]))
print('\n'.join(result))


(days, ques) = map(int, input().strip().split())
nums = list(map(int, input().strip().split()))
xw = []
for i in range(ques):
	xw.append(int(input().strip()))
set = set()
result = []
for i in range(days - 1, -1, -1):
	set.add(nums[i])
	result.append(len(set))
result = result[::-1]
for i in range(ques):
	print(result[xw[i] - 1])


(n, m) = map(int, input().split())
massiv = input().split()
for i in range(0, n):
	massiv[i] = int(massiv[i])
res = [int(0) for i in range(n)]
s = set()
for i in range(n - 1, -1, -1):
	s.add(massiv[i])
	res[i] = len(s)
for i in range(0, m):
	print(res[int(input()) - 1])


import bisect
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = [1] * n
c = [a[len(a) - 1]]
for i in range(n - 2, -1, -1):
	t = bisect.bisect_left(c, a[i])
	if t != len(c) and c[t] == a[i]:
		b[i] = b[i + 1]
	else:
		c.insert(t, a[i])
		b[i] = b[i + 1] + 1
for i in range(m):
	l = int(input())
	print(b[l - 1])


(n, m) = map(int, input().split())
L = [int(i) for i in input().split()]
M = set()
for i in range(n - 1, -1, -1):
	M.add(L[i])
	L[i] = len(M)
str1 = ''
for i in range(m):
	x = int(input())
	str1 += str(L[x - 1]) + '\n'
print(str1)


(n, m) = input().split()
n = int(n)
m = int(m)
first_list = [int(x) for x in input().split()]
second_list = [int(input()) for _ in range(m)]
exists = [False] * (10 ** 5 + 1)
for i in range(n - 1, -1, -1):
	if exists[first_list[i]]:
		first_list[i] = None
	else:
		exists[first_list[i]] = True
result = [0] * (n + 1)
for i in range(n - 1, -1, -1):
	result[i] = result[i + 1] + (1 if first_list[i] != None else 0)
for index in second_list:
	print(result[index - 1])


import sys
input = sys.stdin.readline

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	while x != link[x]:
		x = link[x]
	return x

def union(x, y, size, link):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().split()))
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
(n, m) = int_array()
a = int_array()
ans = []
this = set()
for i in range(n - 1, -1, -1):
	if a[i] not in this:
		this.add(a[i])
	ans.append(len(this))
ans = ans[::-1]
for _ in range(m):
	print(ans[int(input()) - 1])


def sns(n, m):
	a = [0] * 100005
	b = [0] * 100005
	result = []
	c = [False] * 100005
	vn = input()
	vn = vn.split()
	vn = list(map(int, vn))
	for i in range(1, n + 1):
		a[i] = vn[i - 1]
	for i in range(n, 0, -1):
		if not c[a[i]]:
			b[i] += 1
		c[a[i]] = True
	for i in range(n, 0, -1):
		b[i] += b[i + 1]
	for i in range(m):
		result.append(b[int(input())])
	for i in result:
		print(i)
a = input()
b = a.split()
sns(int(b[0]), int(b[1]))


(elements, rows) = (int(x) for x in input().split())
array = [int(x) for x in input().split()]

def solution_func(input_):
	elements = [0] * len(input_)
	cache_exists = set()
	for (index, element) in enumerate(reversed(input_)):
		elements[index] = elements[index - 1]
		if element not in cache_exists:
			cache_exists.add(element)
			elements[index] += 1
	return elements
dp_elements = solution_func(array)
for _ in range(rows):
	print(dp_elements[-int(input())])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
L = []
for i in range(m):
	L.append(int(input()))
s = set()
d = [-1] * n
for i in range(n - 1, -1, -1):
	s.add(a[i])
	d[i] = len(s)
for i in range(m):
	print(d[L[i] - 1])


(n_a, n_l) = [int(x) for x in input().split()]
a = input().split()
b = {}
s = set()
for i in range(n_a - 1, -1, -1):
	s.add(a[i])
	b[i] = len(s)
for i in range(n_l):
	print(b[int(input()) - 1])


(n, m) = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
B = set()
C = [0] * n
D = []
for i in range(n - 1, -1, -1):
	B.add(A[i])
	C[i] = len(B)
for i in range(m):
	x = int(input())
	print(C[x - 1])


def go():
	(n, m) = (int(i) for i in input().split(' '))
	a = [int(i) for i in input().split(' ')]
	keep = set()
	o = {}
	output = ''
	for i in range(n - 1, -1, -1):
		keep.add(a[i])
		o[i] = len(keep)
	for _ in range(m):
		i = int(input())
		output += '{}\n'.format(o[i - 1])
	return output
print(go())


import sys
(n, k) = map(int, sys.stdin.readline().rstrip().split(' '))
l = list(map(int, sys.stdin.readline().rstrip().split(' ')))
check = [0] * 100005
res = [0] * n
c = 0
for i in range(n - 1, -1, -1):
	if not check[l[i]]:
		c = c + 1
		check[l[i]] = 1
	res[i] = c
n = n
while k:
	f = int(sys.stdin.readline().rstrip('\r\n'))
	print(res[f - 1])
	k -= 1


q = input().split()
n = int(q[0])
m = int(q[1])
a = input().split()
for i in range(n):
	a[i] = int(a[i])
b = [0]
d = []
for i in range(10 ** 5):
	d.append(False)
for i in range(1, n + 1):
	if d[a[n - i] - 1] == False:
		d[a[n - i] - 1] = True
		b.append(b[-1] + 1)
	else:
		b.append(b[-1])
b.reverse()
for i in range(m):
	e = int(input())
	print(b[e - 1])


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
dli = {}
a = set()
for x in range(0, len(arr)):
	a.add(arr[n - x - 1])
	dli[n - x - 1] = len(a)
for x in range(0, m):
	print(dli[int(input()) - 1])


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
t = [int(input()) for i in range(m)]
dp = set({})
tab = [0] * n
j = n - 1
for i in l[::-1]:
	if i in dp:
		tab[j] = len(dp)
	else:
		dp.add(i)
		tab[j] = len(dp)
	j = j - 1
for i in t:
	print(tab[i - 1])


(n, m) = map(int, input().split())
l = [i for i in input().split()]
query = []
dp = {}
while l:
	dp[l.pop()] = 1
	query += [len(dp)]
for _ in range(m):
	print(query[n - int(input())])


(n, m) = map(int, input().split())
l1 = list(map(int, input().split()))
l2 = []
l1 = l1[::-1]
d1 = {}
for i in range(0, n):
	if i == 0:
		d1[l1[i]] = 1
		l2.append(1)
	elif l1[i] not in d1:
		l2.append(l2[i - 1] + 1)
		d1[l1[i]] = 1
	else:
		l2.append(l2[i - 1])
l2 = l2[::-1]
for i in range(0, m):
	x = int(input())
	print(l2[x - 1])


(n, m) = map(int, input().split())
l = input().split()
l = l[::-1]
t = [0] * n
s = set()
for i in range(n):
	s.add(l[i])
	t.append(len(s))
sol = []
while m > 0:
	sol.append(str(t[-int(input())]))
	m -= 1
print('\n'.join(sol))


(n, m) = map(int, input().strip().split())
list1 = list(map(int, input().strip().split()))
hashmap = [0 for a in range(0, max(list1) + 1)]
list1.reverse()
dp = [1]
hashmap[list1[0]] += 1
for a in range(1, len(list1)):
	hashmap[list1[a]] += 1
	if hashmap[list1[a]] > 1:
		dp.append(dp[-1])
	else:
		dp.append(dp[-1] + 1)
for d in range(0, m):
	k = int(input())
	print(dp[n - k])


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
cnt = []
d = {}
while arr:
	d[arr.pop()] = 1
	cnt.append(len(d))
for _ in range(m):
	x = int(input())
	print(cnt[n - x])


(n, m) = map(int, input().split())
a = [0] + [int(x) for x in input().split()]
p = []
for _ in range(m):
	p.append(int(input()))
dp = [1] * (n + 1)
ind = [0] * (10 ** 5 + 1)
for i in range(1, n + 1):
	if ind[a[n - i + 1]] == 1:
		dp[n - i] = dp[n - i + 1]
	else:
		dp[n - i] = dp[n - i + 1] + 1
	ind[a[n - i + 1]] = 1
for y in p:
	print(dp[y - 1] - 1)


(n, m) = list(map(int, input().split()))
arr = list(map(int, input().split()))
queries = []
for _ in range(m):
	queries.append(int(input()))
ss = set()
unique = [0] * len(arr)
for i in range(len(arr) - 1, -1, -1):
	ss.add(arr[i])
	unique[i] = len(ss)
for query in queries:
	print(unique[query - 1])


def findDistinctNumbers(n, m, a, l):
	dif_numbers = [0] * n
	mapCount = {}
	for i in range(n - 1, -1, -1):
		if not mapCount.get(a[i]):
			mapCount[a[i]] = 1
		else:
			mapCount[a[i]] += 1
		if i == n - 1:
			dif_numbers[i] = 1
		else:
			dif_numbers[i] = dif_numbers[i + 1] + (1 if mapCount[a[i]] == 1 else 0)
	for query in l:
		print(dif_numbers[query - 1])
(n, m) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
l = []
for i in range(m):
	l.append(int(input()))
findDistinctNumbers(n, m, a, l)


(n, m) = map(int, input().split())
b = []
dp = []
for a in range(n + 1):
	dp.append(0)
result = []
for numb in range(100002):
	b.append(False)
nn = list(map(int, input().split()))
for i in range(n, 0, -1):
	if i == n:
		dp[i] = 1
		b[nn[n - 1]] = True
	elif b[nn[i - 1]]:
		dp[i] = dp[i + 1]
	else:
		dp[i] = dp[i + 1] + 1
		b[nn[i - 1]] = True
for j in range(m):
	number = int(input())
	result.append(int(dp[number]))
for num in result:
	print(num)


p = []
(n, f) = map(int, input().split())
a = list(map(int, input().split()))
s = set()
for i in range(n):
	s.add(a[n - i - 1])
	a[n - i - 1] = len(s)
for i in range(f):
	p = int(input())
	print(a[p - 1])


import heapq as hp
import collections
import bisect

def unpack(func=int):
	return map(func, input().split())

def l_unpack(func=int):
	return list(map(func, input().split()))

def s_unpack(func=int):
	return sorted(map(func, input().split()))

def range_n():
	return range(int(input()))

def counter(a):
	d = {}
	for x in a:
		if x in d:
			d[x] += 1
		else:
			d[x] = 1
	return d

def setbits(x):
	count = 0
	while x:
		x = x & x - 1
		count += 1
	return count

def getint():
	return int(input())

def same_sign(sym, x):
	return not (sym > 0) ^ (x > 0)

def main():
	(n, m) = unpack()
	a = l_unpack()
	q = [getint() - 1 for i in range(m)]
	d = counter(a)
	arr = [0] * n
	arr[0] = len(d)
	for i in range(1, n):
		if a[i - 1] in d:
			d[a[i - 1]] -= 1
			if not d[a[i - 1]]:
				del d[a[i - 1]]
		arr[i] = len(d)
	for e in q:
		print(arr[e])
main()


(n, m) = map(int, input().split())
Arr = list(map(int, input().split()))
L = []
Var_dic = {}
dp = [0 for i in range(n + 1)]
for i in range(m):
	L.append(int(input()))
for i in range(n - 1, -1, -1):
	if Arr[i] not in Var_dic:
		Var_dic[Arr[i]] = 0
	dp[i + 1] = len(Var_dic)
for M in L:
	print(dp[M])


(n, x) = map(int, input().split())
a = list(map(int, input().strip().split()))
m = {}
distint = [0] * n
distint[-1] = 1
m[a[-1]] = 1
for i in range(n - 2, -1, -1):
	if a[i] in m:
		m[a[i]] += 1
		distint[i] = distint[i + 1]
	else:
		m[a[i]] = 1
		distint[i] = distint[i + 1] + 1
for i in range(x):
	xx = int(input())
	print(distint[xx - 1])


(n, m) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
b = set()
for x in range(0, n):
	b.add(a[n - 1 - x])
	a[n - x - 1] = len(b)
for x in range(0, m):
	t = int(input())
	print(a[t - 1])


def solve(lst_n, lst_m):
	distinct_numbers = 0
	count_distinct = [0] * (len(lst_n) + 1)
	numbers = {}
	for i in reversed(range(len(lst_n))):
		number = lst_n[i]
		if number not in numbers:
			distinct_numbers += 1
			numbers[number] = True
		count_distinct[i + 1] = distinct_numbers
	for item in lst_m:
		print(count_distinct[item])
(n, m) = map(int, input().split())
lst_n = [int(x) for x in input().split()]
lst_m = []
for i in range(m):
	item = int(input())
	lst_m.append(item)
solve(lst_n, lst_m)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
suffix_sum = [0 for i in range(n)]
seen = {}
for i in range(n - 1, -1, -1):
	if a[i] not in seen:
		suffix_sum[i] += 1
		seen[a[i]] = True
for i in range(n - 1, -1, -1):
	if i == n - 1:
		continue
	suffix_sum[i] += suffix_sum[i + 1]
while m:
	print(suffix_sum[int(input()) - 1])
	m -= 1


line = input().split(' ')
(n, m) = (int(line[0]), int(line[1]))
result = {}
s = set()
line = input().split(' ')
count = len(line)
for i in range(count):
	s.add(int(line[count - 1 - i]))
	result[count - i] = len(s)
a = []
for i in range(m):
	c = int(input())
	a.append(c)
for c in a:
	print(result[c])


(n, m) = map(int, input().split())
list = [int(x) for x in input().split()]
dp = [0 for x in range(n)]
exist = set()
for i in range(n - 1, -1, -1):
	exist.add(list[i])
	dp[i] = len(exist)
for i in range(m):
	print(dp[int(input()) - 1])


(n, m) = map(int, input().split())
a = input().split()
ad = set()
indexes = [int(input()) - 1 for _ in range(m)]
for y in range(n - 1, -1, -1):
	ad.add(a[y])
	a[y] = len(ad)
for x in indexes:
	print(a[x])


(n, m) = map(int, input().split())
L = []
K = set()
N = list(map(int, input().split()))
for i in range(n):
	K.add(N[-1 - i])
	L.append(len(K))
for _ in range(m):
	print(L[-int(input())])


import sys
input = sys.stdin.buffer.readline
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
ans = [0] * n
d = {}
count = 0
for i in range(n - 1, -1, -1):
	if l[i] not in d:
		count += 1
		d[l[i]] = 1
	ans[i] = count
for i in range(m):
	print(ans[int(input()) - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
H = set()
diff = [0] * (n + 5)
cur = 0
for i in range(n - 1, -1, -1):
	H.add(a[i])
	diff[i] = len(H)
print('\n'.join((str(diff[int(input()) - 1]) for _ in range(m))))


(n, m) = map(int, input().split())
visited = [False] * 100001
l = [int(x) for x in input().split()]
prefix_array = [0] * n
count = 0
for i in range(n - 1, -1, -1):
	if not visited[l[i]]:
		visited[l[i]] = True
		count += 1
	prefix_array[i] += count
for _ in range(m):
	print(prefix_array[int(input()) - 1])


import sys
(n, m) = map(int, sys.stdin.readline().split(' '))
a = list(map(int, sys.stdin.readline().split(' ')))
arr = []
s = set()
for i in range(0, n):
	j = n - i - 1
	s.add(a[j])
	arr.append(len(s))

def f(i):
	return str(arr[n - i])
for i in range(m):
	sys.stdout.write(f(int(sys.stdin.readline())) + '\n')


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
s = set()
ans = {}
c = 0
for i in range(n - 1, -1, -1):
	if a[i] not in s:
		s.add(a[i])
		c += 1
	ans[i] = c
for j in range(m):
	print(ans[int(input()) - 1])


(n, q) = map(int, input().split())
arr = list(map(int, input().split()))
dp = [1] * n
a = set()
for i in range(n - 1, -1, -1):
	a.add(arr[i])
	dp[i] = len(a)
for i in range(q):
	x = int(input())
	print(dp[x - 1])


(n, m) = map(int, input().split())
num = input()
pos = []
for i in range(0, m):
	l = input()
	pos.append(l)

def problem8(n, m, num, pos):
	num = num.split()
	lista = [0] * m
	listaaux = [0] * n
	s = set()
	for i in range(n - 1, -1, -1):
		if num[i] not in s:
			s.add(num[i])
		listaaux[int(i)] = len(s)
	for i in pos:
		print(listaaux[int(i) - 1])
problem8(n, m, num, pos)


(n, m) = [int(x) for x in input().split()]
ar = [int(x) for x in input().split()]
diff = set([])
precalc = []
for el in reversed(ar):
	diff.add(el)
	precalc.append(len(diff))
precalc = precalc[::-1]
for _ in range(m):
	print(precalc[int(input()) - 1])


(n, m) = map(int, input().split())
l = [int(x) for x in input().split()]
ans = [0] * n
s = set(l)
for i in range(n - 1, -1, -1):
	if l[i] in s:
		ans[i] = 1
		s.remove(l[i])
	if s == {}:
		break
for i in range(n - 2, -1, -1):
	ans[i] += ans[i + 1]
for i in range(m):
	a = int(input())
	print(ans[a - 1])


(n, m) = [int(i) for i in input().split(' ')]
a = [int(i) for i in input().split(' ')]
l = []
for i in range(m):
	l.append(int(input()))
ans = []
s = set()
for i in range(n - 1, -1, -1):
	s.add(a[i])
	ans.append(len(s))
ans.reverse()
for i in range(m):
	print(ans[l[i] - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
adic = {}
for i in range(n):
	if a[i] in adic:
		adic[a[i]] += 1
	else:
		adic[a[i]] = 1
ans = [0] * n
for i in range(n):
	if a[i] in adic:
		if adic[a[i]] == 1:
			adic.pop(a[i])
			ans[i] += 1
		else:
			adic[a[i]] -= 1
	ans[i] += len(adic)
for i in range(m):
	print(ans[int(input()) - 1])


__author__ = 'asmn'
(n, m) = tuple(map(int, input().split()))
a = list(map(int, input().split()))
s = set()
ans = [0] * n
for i in reversed(range(n)):
	s.add(a[i])
	ans[i] = len(s)
for i in range(m):
	print(ans[int(input()) - 1])


import sys
(n, m) = map(int, sys.stdin.readline().split())
arr = list(map(int, sys.stdin.readline().split()))
ans = [0 for j in range(m)]
q = []
for j in range(m):
	x = int(sys.stdin.readline().strip())
	q.append([x, j])
q.sort(key=lambda y: y[0])
q = q[::-1]
s = set()
top = n - 1
for j in range(m):
	cur = q[j][0]
	ind = q[j][1]
	for i in range(top, cur - 2, -1):
		s.add(arr[i])
	ans[ind] = len(s)
	top = cur - 1
for j in ans:
	print(j)


(n, m) = map(int, input().split())
lst = list((int(num) for num in input().split()))[:n]
count = set()
lst1 = [0] * n
for i in range(n):
	count.add(lst[n - i - 1])
	lst[n - i - 1] = len(count)
for i in range(0, m):
	k = int(input())
	print(lst[k - 1])


(n, m) = map(int, input().split())
l = input().split()
l = [int(x) for x in l]
q = []
q1 = []
for i in range(m):
	q.append(int(input()))
for j in range(m):
	q1.append([q[j], j])
q1.sort()
r = [0] * m
i = m - 1
j = n - 1
a = set([])
while j >= 0:
	a.add(l[j])
	j -= 1
	while q1[i][0] >= j + 2 and i >= 0:
		r[q1[i][1]] = len(a)
		i -= 1
for i in r:
	print(i)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
k = [0] * n
p = [0] * (10 ** 5 + 1)
k[n - 1] = 1
p[a[n - 1]] = 1
for i in range(n - 2, -1, -1):
	if p[a[i]] == 0:
		k[i] = k[i + 1] + 1
		p[a[i]] = 1
	else:
		k[i] = k[i + 1]
for i in range(m):
	j = int(input())
	print(k[j - 1])


(a, b) = map(int, input().split())
k = []
c = list(map(int, input().split()))
d = dict()
for i in c:
	d[i] = d.get(i, 0) + 1
for i in c:
	k += [len(d)]
	d[i] -= 1
	if d[i] == 0:
		d.pop(i)
for _ in ' ' * b:
	print(k[int(input()) - 1])


(n, m) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
ans = [0] * n
current = 0
occurs = set()
for i in range(n - 1, -1, -1):
	if a[i] not in occurs:
		occurs.add(a[i])
		current += 1
	ans[i] = current
for i in range(m):
	l = int(input())
	print(ans[l - 1])


(n, m) = map(int, input().split())
a = [int(i) for i in input().split()]
b = [0] * (10 ** 5 + 1)
p = [0] * n + [0]
for i in range(len(a) - 1, -1, -1):
	if b[a[i]] == 0:
		b[a[i]] += 1
		p[i] = p[i + 1] + 1
	else:
		p[i] = p[i + 1]
for i in range(m):
	k = int(input())
	print(p[k - 1])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
l = []
for idx in range(m):
	num = int(input())
	l.append(num)
ready_list = []
pre_sets = set()
a.reverse()
for i in range(n):
	pre_sets.add(a[i])
	ready_list.append(len(pre_sets))
ready_list.reverse()
a.reverse()
for m_elem in l:
	print(ready_list[m_elem - 1])


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
suffix_dupe_count = [0 for _ in range(n)]
integer_set = set([arr[n - 1]])
suffix_dupe_count[n - 1] = 1
for i in reversed(range(n - 1)):
	if arr[i] in integer_set:
		suffix_dupe_count[i] = suffix_dupe_count[i + 1]
	else:
		suffix_dupe_count[i] = suffix_dupe_count[i + 1] + 1
		integer_set.add(arr[i])
for _ in range(m):
	l = int(input()) - 1
	print(suffix_dupe_count[l])


(n, m) = map(int, input().split())
s = list(map(int, input().split()))
ans = [1] * n
seen = set()
seen.add(s[n - 1])
for i in range(n - 2, -1, -1):
	if s[i] not in seen:
		ans[i] = ans[i + 1] + 1
		seen.add(s[i])
	else:
		ans[i] = ans[i + 1]
for i in range(m):
	k = int(input())
	print(ans[k - 1])


(a, b) = map(int, input().split())
z = list(map(int, input().split()))
(d, c, w) = (set(), [], 0)
for i in range(a - 1, -1, -1):
	if z[i] in d:
		pass
	else:
		d.add(z[i])
		w += 1
	c.append(w)
c.reverse()
for i in range(b):
	q = int(input())
	print(c[q - 1])


from sys import stdin
(n, m) = list(map(int, stdin.readline().split()))
a = list(map(int, stdin.readline().split()))
distinct = [0] * n
distinct[-1] = 1
d = {a[-1]: 1}
for i in range(n - 2, -1, -1):
	distinct[i] = distinct[i + 1]
	if a[i] not in d:
		distinct[i] += 1
		d[a[i]] = 1
for _ in range(m):
	l = int(stdin.readline())
	print(distinct[l - 1])


temp = list(map(int, input().split(' ')))
numbers = list(map(int, input().split(' ')))
n = temp[0]
m = temp[1]
resol = [0 for _ in range(max(numbers) + 1)]
resol[numbers[n - 1]] = 1
aux_sum = [0 for _ in range(n + 1)]
aux_sum[n - 1] = 1
for i in range(n - 2, -1, -1):
	aux = numbers[i]
	aux_sum[i] = aux_sum[i + 1]
	if not resol[aux]:
		resol[aux] = 1
		aux_sum[i] += 1
answer_array = []
for j in range(m):
	answer_array.append(aux_sum[int(input()) - 1])
print('\n'.join((str(elem) for elem in answer_array)))


(n, m) = input().split()
n = int(n)
m = int(m)
arr = list(map(int, input().split()))
dp = [1] * len(arr)
seen = set()
seen.add(arr[-1])
for i in range(len(arr) - 2, -1, -1):
	if arr[i] not in seen:
		dp[i] = dp[i + 1] + 1
		seen.add(arr[i])
	else:
		dp[i] = dp[i + 1]
for i in range(m):
	c = int(input())
	print(dp[c - 1])


(n, m) = list(map(int, input().split(' ')))
arr = list(map(int, input().split(' ')))
anss = []
sett = set()
for i in range(n - 1, -1, -1):
	sett.add(arr[i])
	anss.append(len(sett))
anss.reverse()
answers = []
for i in range(m):
	answers.append(anss[int(input()) - 1])
for ans in answers:
	print(ans)


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
ans = []
rev = []
lists = set()
for i in range(n - 1, -1, -1):
	lists.add(arr[i])
	rev.append(len(lists))
ans = rev[::-1]
for _ in range(m):
	q = int(input())
	print(ans[q - 1])


import sys

def input():
	return sys.stdin.readline().strip()
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
ans = [0] * n
b = set()
for i in range(n):
	b.add(a[-1 - i])
	ans[-1 - i] = len(b)
for i in range(m):
	print(ans[int(input()) - 1])


(n, m) = map(int, input().split())
nums = list(map(int, input().split()))
repeats = {}
repeats[nums[-1]] = None
counts = [0 for i in range(n - 1)]
counts.append(1)
for i in range(n - 2, -1, -1):
	if nums[i] not in repeats:
		repeats[nums[i]] = None
		counts[i] = counts[i + 1] + 1
	else:
		counts[i] = counts[i + 1]
for i in range(m):
	querry = int(input())
	print(counts[querry - 1])


from collections import defaultdict

def main():
	(n, m) = map(int, input().split())
	array = list(map(int, input().split()))
	cache = dict()
	br = ''
	distincts = set()
	for i in range(len(array) - 1, -1, -1):
		distincts.add(array[i])
		cache[i] = len(distincts)
	for _ in range(m):
		mi = int(input()) - 1
		if _ > 0:
			br = '\n'
		print(f'{br}{cache[mi]}', end='')
main()


import sys
(n, m) = list(map(int, sys.stdin.readline().split()))
arr = list(map(int, sys.stdin.readline().split()))
ans = []
d = {}
cnt = 0
for i in range(n - 1, -1, -1):
	if arr[i] not in d:
		d[arr[i]] = 1
		cnt += 1
		ans.append(cnt)
	else:
		ans.append(cnt)
ans = ans[-1::-1]
for i in range(m):
	x = int(input())
	sys.stdout.write(str(ans[x - 1]) + '\n')


(N, M) = map(int, input().split())
A = list(map(int, input().split()))
An = [0] * len(A)
num = set()
for i in range(len(A) - 1, -1, -1):
	num.add(A[i])
	An[i] = len(num)
for m in range(M):
	print(An[int(input()) - 1])


def main():
	from sys import stdin, stdout
	import collections
	(n, m) = map(int, stdin.readline().split())
	arr = list(map(int, stdin.readline().split()))
	s = set()
	ans = collections.deque([0])
	for i in range(n - 1, -1, -1):
		if arr[i] in s:
			ans.appendleft(ans[0])
		else:
			ans.appendleft(ans[0] + 1)
			s.add(arr[i])
	for _ in range(m):
		a = int(stdin.readline()) - 1
		stdout.write(str(ans[a]) + '\n')
main()


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nlargest, nsmallest, _heapify_max, _heapreplace_max
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as c
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from fractions import Fraction
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
(n, m) = sp()
arr = l()
s = set()
dp = dd(int)
for i in range(n - 1, -1, -1):
	s.add(arr[i])
	dp[i + 1] = len(s)
for i in range(m):
	out(dp[int(data())])


(n, m) = map(int, input().split())
a = list(reversed(list(map(int, input().split()))))
l = []
for _ in range(m):
	l.append(int(input()))
s = set()
c_sum = [None for _ in range(n)]
for i in range(n):
	s.add(a[i])
	c_sum[i] = len(s)
for e in l:
	print(c_sum[n - e])


from collections import defaultdict

def solve():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = []
	res = defaultdict(int)
	for i in range(n):
		res[a[i]] += 1
	prev = len(list(res.values()))
	res[a[0]] -= 1
	ans = []
	ans.append(prev)
	for i in range(1, n):
		if res[a[i - 1]] == 0:
			prev -= 1
		res[a[i]] -= 1
		ans.append(prev)
	print('\n'.join((str(ans[int(input()) - 1]) for _ in range(m))))
solve()


p = input
(n, m) = map(int, p().split())
n -= 1
dp = []
arr = [int(i) for i in p().split()]
s = set()
for i in range(n, -1, -1):
	s.add(arr[i])
	dp.append(len(s))
for i in range(m):
	print(dp[n - int(p()) + 1])


import math
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
d = dict()
ans = [0] * n
for i in range(n):
	if l[i] not in d:
		d.update({l[i]: 1})
	else:
		d[l[i]] += 1
ans[0] = len(d)
for i in range(1, n):
	d[l[i - 1]] -= 1
	if d[l[i - 1]] == 0:
		del d[l[i - 1]]
	ans[i] = len(d)
for i in range(m):
	ind = int(input())
	print(ans[ind - 1])


(n, m) = map(int, input().split(' '))
arrn = [int(x) for x in input().split(' ')]
arrm = []
for i in range(m):
	elem = int(input())
	arrm.append(elem)
dicta = {}
dictb = {}
dictb[n] = 0
for i in range(m):
	dictb[arrm[i]] = 0
for i in range(n):
	dicta[arrn[i]] = -1
for i in range(n - 1, -1, -1):
	if dicta[arrn[i]] == -1:
		dicta[arrn[i]] = 1
		dictb[i] = dictb[i + 1] + 1
	else:
		dictb[i] = dictb[i + 1]
for i in range(m):
	print(dictb[arrm[i] - 1])


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
ans = [0] * n
d = [0] * 100010
c = 0
for i in range(n - 1, -1, -1):
	if d[arr[i]] == 1:
		ans[i] = c
	else:
		d[arr[i]] += 1
		c += 1
		ans[i] = c
for i in range(m):
	x = int(input())
	print(ans[x - 1])


(n, m) = map(int, input().split())
L = input().split()
a = set()
for i in range(1, n + 1):
	a.add(L[-i])
	L[-i] = str(len(a))
c = []
for j in range(m):
	c.append(L[int(input()) - 1])
print('\n'.join(c))


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = []
uniques = set()
uniques_count = 0
for i in range(n - 1, -1, -1):
	if a[i] not in uniques:
		uniques.add(a[i])
		uniques_count += 1
	b.append(uniques_count)
b.reverse()
while m:
	m -= 1
	i = int(input())
	i -= 1
	print(b[i])


(n, m) = map(int, input().split())
lista = list(map(int, input().split()))
memo = [1]
num_rep = {lista[-1]}
for i in range(len(lista) - 2, -1, -1):
	if lista[i] in num_rep:
		memo.append(memo[-1])
	else:
		memo.append(memo[-1] + 1)
		num_rep.add(lista[i])
memo.reverse()
for i in range(m):
	print(memo[int(input()) - 1])