var input = readline().split(' ').map(Number), n = input[0], m = input[1];
var a = readline().split(' ').map(Number);

var mySet = new Set();
var res = [];
for (var i = a.length - 1; i >= 0; i--) {
    if (!mySet.has(a[i]))
        mySet.add(a[i]);
    res[i] = mySet.size;
}

str = '';
for (var i = 0; i < m; i++) {
    var l = readline().split(' ').map(Number);
    str += res[l-1] + '\n';
}
write(str);

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

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

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

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

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

Input

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

Output

6
6
6
6
6
5
4
3
2
1
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let lenthOfInput = Number(inputString[0].split(" ")[0]);
    let lengthOfLocations = Number(inputString[0].split(" ")[1]);
    let input = inputString[1].split(" ");
    let locations = inputString.slice(2);

    solution(lenthOfInput, lengthOfLocations, input, locations);
});

function solution(lenthOfInput, lengthOfLocations, input, locations) {

    let solutionArray = [];
    let frequencyMap = {};
    let perfixSumForDistinct = [];

    for (let index = lenthOfInput - 1; index > -1; index--) {

        if (!frequencyMap[input[index]]) {

            //if (index)
                perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] ? perfixSumForDistinct[index + 1] + 1 : 1

          //  else
            //    perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] ? perfixSumForDistinct[index + 1] + 1 : 1
        }

        if (frequencyMap[input[index]]) {
            perfixSumForDistinct[index] = perfixSumForDistinct[index + 1]
        }

        frequencyMap[input[index]] = 1;
    }

    for (let index = 0; index < lengthOfLocations; index++) {
        let solution = perfixSumForDistinct[locations[index] - 1]
        solutionArray.push(solution);
        solutionArray.push("\n")
    }

    console.log(solutionArray.join(""));

}

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

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

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

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

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

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

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let lenthOfInput = Number(inputString[0].split(" ")[0]);
    let lengthOfLocations = Number(inputString[0].split(" ")[1]);
    let input = inputString[1].split(" ");
    let locations = inputString.slice(2);

    solution(lenthOfInput, lengthOfLocations, input, locations);
});

function solution(lenthOfInput, lengthOfLocations, input, locations) {

    let solutionArray = [];
    let frequencyMap = {};
    let perfixSumForDistinct = [];

    for (let index = lenthOfInput - 1; index > -1; index--) {

        if (!frequencyMap[input[index]]) {

            perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] ? perfixSumForDistinct[index + 1] + 1 : 1
        }

        if (frequencyMap[input[index]]) {
            perfixSumForDistinct[index] = perfixSumForDistinct[index + 1]
        }

        frequencyMap[input[index]] = 1;
    }

    for (let index = 0; index < lengthOfLocations; index++) {
        let solution = perfixSumForDistinct[locations[index] - 1]
        solutionArray.push(solution);
        solutionArray.push("\n")
    }

    console.log(solutionArray.join(""));

}

const input = [];

const RL = require('readline').createInterface({
   input : process.stdin,
   output : process.stdout
});

RL.on('line', line => input.push(line));

RL.on('close', () => {
  const [n, m] = input[0].split(' ').map(x => parseInt(x));
  const nums = input[1].split(' ').map(x => parseInt(x));

  const map = {}; const data = []; let cnt = 0;
  for (let i = nums.length - 1; i >= 0; i -= 1) {
    let x = nums[i];
    if (map[x] === undefined) { cnt += 1; map[x] = true; }
    data[i] = cnt;
  }

  const answer = [];
  for (let i = 0; i < m; i += 1) {
    let x = parseInt(input[i+2]);
    answer.push(data[x-1]);
    answer.push('\n');
  }

  console.log(answer.join(""))
});

'use strict';

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    let valuesLen = Number(inputString[0].split(" ")[0]);
    let numLen = Number(inputString[0].split(" ")[1]);
    let values = inputString[1].split(" ");
    let nums = inputString.slice(2);
    distinctNumbers(valuesLen, numLen, values, nums);
});
function distinctNumbers(valuesLen, numLen, values, nums) {
    var freqArr = {};
    var perfixSum = [];
    var distincts = 0;
    var solutions = [];
    for (let i = 0; i < valuesLen; i++) {
        if (!freqArr[values[i]]) {
            freqArr[values[i]] = 1;
            distincts++;
        }
        else {
            freqArr[values[i]]++;
        }
    }
    for (let i = 0; i < valuesLen; i++) {
        perfixSum[i] = distincts;
        if (freqArr[values[i]] == 1)
            distincts--;
        else {
            freqArr[values[i]]--
        }
    }
    for (let i = 0; i < numLen; i++) {
        // console.log(perfixSum[Number(nums[i]) - 1]);
        solutions.push(perfixSum[Number(nums[i]) - 1]);
        solutions.push('\n');
    }
    console.log(solutions.join(""));
}

;(function() {

	var n = readline().split(' '),
		m = +n[1],
		t = {}, k = 0;
		a = readline().split(' ').map(Number);
	n = +n[0];

	for (var i = n - 1; i >= 0; i--) {
		if (!t.hasOwnProperty(a[i])) {
			t[a[i]] = true;
			k++
		}
		a[i] = k;
	}

	for (var i = 0; i < m; i++)
		print(a[+readline() - 1]);

}).call(this);

const memo1 = Array(100000);
const memo2 = Array(100000);

function check(arr) {
  var k = 0;
  for (var i = arr.length - 1; i >= 0; i--) {
    if (!memo1[arr[i]]) {
      memo1[arr[i]] = true;
      k++;
    }
    memo2[i] = k;
  }
}

function resolve(arr, ls) {
  check(arr);
  for (var i = 0; i < ls.length; i++) {
    print(memo2[ls[i] - 1]);
    // console.log(memo2[ls[i] - 1]);
  }
}

/*
const arr = '1 2 3 4 1 2 3 4 100000 99999'.split(' ');
const l = '1 2 3 4 5 6 7 8 9 10'.split(' ');

resolve(arr, l);
*/

const p = readline().split(' ');
const m = parseInt(p[1], 10);
const arr = readline().split(' ');
const ls = [];

for (var i = 0; i < m; i++) {
  var l = readline();
  ls.push(l);
}

resolve(arr, ls);

if(!this.print){
	print=console.log;
	readline=function(){
		var data = require('fs').readFileSync('./2B.in','utf8').split('\n');
		var i=0;
		return function(){
			return data[i++];
		}
	}();
}
l=readline().split(' ');
n=+l[0];
m=+l[1];
a=readline().split(' ');

var map={};
var c=0;
for(var i=n-1;i>=0;i--){
	if(map[a[i]]){
		a[i]=c;
	}else{
		map[a[i]]=true;
		a[i]=++c;
	}
}
while(m--){
	print(a[readline()-1]);
}

'use strict';

// const rlLib = require('readline');

// const rl = rlLib.createInterface({
//   input: process.stdin,
//   output: process.stdout
// });

// let inputs = [];
// let allCount = 12;
// let currentLine = 0;

// rl.on('line', (input) => {
//  inputs.push(input);
//  if (inputs.length >= allCount) {
//      main();

//      rl.close();
//  }
// });

// function readline() {
//  return inputs[currentLine++];
// }
// function print() {
//  console.log.apply(this, arguments);
// }

// // function main() {
// //     let count = +readline();
// //     let arr = readline().split(' ').map(function(e) {return parseInt(e, 10);});
// //     print(func(arr));
// // }

// /**
//  * @param {number} s
//  * @param {number[]} nums
//  * @return {number}
//  */
//  function main() {
    let count = +(readline().split(' ')[1]);
    let arr = readline().split(' ').map(function(e) {return parseInt(e, 10);});
    let indexes = [];
    let results = [];

    for (let i = 0; i < count; i++) {
        indexes.push(+(readline()));
    }

    let s = new Set();

    for (let i = arr.length - 1; i >= 0; i--) {
        if (s.has(arr[i])) {
            results[i] = results[i + 1] || 0;
        } else {
            s.add(arr[i]);
            results[i] = (results[i + 1] || 0) + 1;
        }
    }
    print(indexes.map(function(e) {return results[e - 1]}).join('\n'));

    // var
    //     commonSum = arr.reduce(function(s, e) {return s + e;}),
    //     sum = [arr[0], commonSum - arr[0] - arr[arr.length - 1], arr[arr.length - 1]],
    //     result = {};

    // var a = function a(sum, i, j) {
    //     if ( j - i <= 1 || result[[i, j].join('!')]) {
    //         return;
    //     }

    //     if (sum[0] === sum[1] && sum[1] === sum[2]) {
    //         result[[i, j].join('!')] = 1;
    //     }

    //     a([sum[0]+ arr[i + 1], sum[1] - arr[i + 1], sum[2]], i + 1, j);
    //     a([sum[0], sum[1] - arr[j - 1], sum[2] + arr[j - 1]], i, j - 1);
    // }

    // a(sum, 0, arr.length - 1);

    // print(Object.keys(result).length;
// };

function main() {
    var line = readline().split(' ').map(Number);
    var n = line[0];
    var m = line[1];
    var data = readline().split(' ').map(Number);
    var dp = [];
    dp[n-1] = 1;
    var all = {}
    all[data[n-1]] = true;
    for(var i=n-2;i>=0;i--){
        if(all[data[i]]){
            dp[i] = dp[i+1]
        } else {
            dp[i] = dp[i+1] + 1;
            all[data[i]] = true;
        }
    }
    for(var i=0;i<m;i++){
        print(dp[(Number(readline())-1)])
    }
}

main()

var input = readline().split(' ');
var n = parseInt(input[0], 10);
var m = parseInt(input[1], 10);

var numbers = readline().split(' ');

var dif = new Set();
var count = [];

for(var i = n - 1; i > -1; i--) {
    dif.add(parseInt(numbers[i]));
    count.push(dif.size);
}

for(var i = 0; i < m; i++) {
    index = readline();
    print(count[n-parseInt(index,10)]);
}

var n = readline().split(/\s/gi).map(Number), m = n[1], n = n[0],
			arr = readline().split(/\s/gi),
			filterArr = [], map = {}, temp = {};

		for(var i = n - 1; i >= 0; i--)	{
			var value = arr[i];

			if(!temp[value])	{
				filterArr.push(value);
				temp[value] = 1;
			}

			map[i + 1] = filterArr.length;
		}

		for(var i = 0; i < m; i++)	{
			print(map[parseInt(readline())]);
		}

const N = 1<<17;

var n, q;
var a;

var dict;
var ans;

var token = [];

var currSize;

function initializeData() {
  a = new Array(N);
  dict = {};
  ans = new Array(N);
}

initializeData();

token = readline().split(' ');
n = parseInt(token[0]);
q = parseInt(token[1]);

token = readline().split(' ');
for(var i=0;i<n;i++) {
  a[i+1] = parseInt(token[i]);
}

currSize = 0;

for(var i=n;i>=1;i--) {
  if(dict[a[i]]==null) {
    ++currSize;
    dict[a[i]]=true;
  }

  ans[i]=currSize;
}

while(q--) {
  var currIdx = parseInt(readline());
  print(ans[currIdx]);
}

const N = 1<<17;

var n, q;
var a;

var dict;
var ans;

var token = [];

var currSize;

function initializeData() {
  a = [];// new Array(N);
  dict = {};
  ans = [];// new Array(N);
}

initializeData();

token = readline().split(' ');
n = parseInt(token[0]);
q = parseInt(token[1]);

token = readline().split(' ');
for(var i=0;i<n;i++) {
  a[i+1] = parseInt(token[i]);
}

currSize = 0;

for(var i=n;i>=1;i--) {
  if(dict[a[i]]==null) {
    ++currSize;
    dict[a[i]]=true;
  }

  ans[i]=currSize;
}

while(q--) {
  var currIdx = parseInt(readline());
  print(ans[currIdx]);
}

"use strict";

var _slicedToArray = (function() {
  function sliceIterator(arr, i) {
    var _arr = [];
    var _n = true;
    var _d = false;
    var _e = undefined;
    try {
      for (
        var _i = arr[Symbol.iterator](), _s;
        !(_n = (_s = _i.next()).done);
        _n = true
      ) {
        _arr.push(_s.value);
        if (i && _arr.length === i) break;
      }
    } catch (err) {
      _d = true;
      _e = err;
    } finally {
      try {
        if (!_n && _i["return"]) _i["return"]();
      } finally {
        if (_d) throw _e;
      }
    }
    return _arr;
  }
  return function(arr, i) {
    if (Array.isArray(arr)) {
      return arr;
    } else if (Symbol.iterator in Object(arr)) {
      return sliceIterator(arr, i);
    } else {
      throw new TypeError(
        "Invalid attempt to destructure non-iterable instance"
      );
    }
  };
})();

var compose = function compose() {
  for (
    var _len = arguments.length, functions = Array(_len), _key = 0;
    _key < _len;
    _key++
  ) {
    functions[_key] = arguments[_key];
  }

  return function() {
    for (
      var _len2 = arguments.length, args = Array(_len2), _key2 = 0;
      _key2 < _len2;
      _key2++
    ) {
      args[_key2] = arguments[_key2];
    }

    return functions.reduce(function(currArgs, func) {
      return func(currArgs);
    }, args);
  };
};

var lineToNumberArray = function lineToNumberArray(str) {
  return str.split(" ").map(function(num) {
    return parseInt(num, 10);
  });
};

var readNumbersLine = compose(
  readline,
  lineToNumberArray
);

var _readNumbersLine = readNumbersLine(),
  _readNumbersLine2 = _slicedToArray(_readNumbersLine, 2),
  n = _readNumbersLine2[0],
  m = _readNumbersLine2[1];

var arr = readNumbersLine().reverse();
var numbers = [];
for (var i = 0; i < m; i++) {
  var number = readNumbersLine();
  numbers.push(number);
}

var map = Object.create(null);
var arrCount = [];
var currCount = 0;

var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;

try {
  for (
    var _iterator = arr.entries()[Symbol.iterator](), _step;
    !(_iteratorNormalCompletion = (_step = _iterator.next()).done);
    _iteratorNormalCompletion = true
  ) {
    var _ref = _step.value;

    var _ref2 = _slicedToArray(_ref, 2),
      key = _ref2[0],
      value = _ref2[1];

    if (!map[value]) {
      currCount++;
      map[value] = 1;
    } else {
      map[value] = map[value] + 1;
    }

    arrCount[key + arr.length - 1] = currCount;
  }
} catch (err) {
  _didIteratorError = true;
  _iteratorError = err;
} finally {
  try {
    if (!_iteratorNormalCompletion && _iterator.return) {
      _iterator.return();
    }
  } finally {
    if (_didIteratorError) {
      throw _iteratorError;
    }
  }
}

numbers.forEach(function(pos) {
  var res = arrCount[arrCount.length - pos];
  print(res);
});

'use strict';

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    // console.log("input ",inputString.slice(2,inputString.length));
    distinctNumbers(inputString[1], inputString.slice(2, inputString.length));
});

function distinctNumbers(values, nums) {
    values = values.split(" ");
    var freqArr = {};
    var perfixSum = [];
    var solution =[];
    var distincts = 0;
    for (let i = 0; i < values.length; i++) {
        if (!freqArr[values[i]]) {
            freqArr[values[i]] = 1;
            distincts += 1;
        } else {
            freqArr[values[i]] += 1;
        }
    }
    for (let i = 0; i < values.length; i++) {
        perfixSum[i] = distincts;
        if (freqArr[values[i]] == 1)
            distincts -= 1;
        else {
            freqArr[values[i]] -= 1
        }
    }
    for (let i = 0; i < nums.length; i++) {
        solution.push(perfixSum[parseInt(nums[i]) - 1])
        solution.push("\n")

    }

        console.log(solution.join(""));

}
// distinctNumbers('10 10', '1 2 3 4 1 2 3 4 100000 99999', '1 2 3 4 5 6 7 8 9 10')'

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

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

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

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

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

Input

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

Output

6
6
6
6
6
5
4
3
2
1
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let lenthOfInput = Number(inputString[0].split(" ")[0]);
    let lengthOfLocations = Number(inputString[0].split(" ")[1]);
    let input = inputString[1].split(" ");
    let locations = inputString.slice(2);

    solution(lenthOfInput, lengthOfLocations, input, locations);
});

function solution(lenthOfInput, lengthOfLocations, input, locations) {

    let solutionArray = [];
    let frequencyMap = {};
    let perfixSumForDistinct = [];

    for (let index = lenthOfInput - 1; index > -1; index--) {

        if (!frequencyMap[input[index]]) {

            if (index)
                perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] ? perfixSumForDistinct[index + 1] + 1 : 1

            else
                perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] ? perfixSumForDistinct[index + 1] + 1 : 1
        }

        if (frequencyMap[input[index]]) {
            perfixSumForDistinct[index] = perfixSumForDistinct[index + 1]
        }

        frequencyMap[input[index]] = 1;
    }

    for (let index = 0; index < lengthOfLocations; index++) {
        let solution = perfixSumForDistinct[locations[index] - 1]
        solutionArray.push(solution);
        solutionArray.push("\n")
    }

    console.log(solutionArray.join(""));

}

const memo1 = {};
const memo2 = {};

function check(arr, i) {
  if (i === -1) {
    return;
  }
  if (!memo1[arr[i]]) {
    memo1[arr[i]] = true;
  }
  memo2[i] = Object.keys(memo1).length;
  check(arr, i - 1);
}

function resolve(arr, ls) {
  check(arr, arr.length - 1);
  for (var i = 0; i < ls.length; i++) {
    print(memo2[ls[i]]);
    //console.log(memo2[ls[i] - 1]);
  }
}

/*
const arr = '1 2 3 4 1 2 3 4 100000 99999'.split(' ');
const l = '1 2 3 4 5 6 7 8 9 10'.split(' ');

resolve(arr, l);
*/

const p = readline().split(' ');
const m = parseInt(p[1], 10);
const arr = readline().split(' ');
const ls = [];

for (var i = 0; i < m; i++) {
  var l = readline();
  ls.push(l);
}

resolve(arr, ls);

var n = readline().split(/\s/gi).map(Number), m = n[1], n = n[0],
			arr = readline().split(/\s/gi),
			filterArr = [], map = {}, result = [], line = [];

		for(var i = 0; i < m; i++)	line.push(parseInt(readline()));

		for(var i = n - 1; i >= 0; i--)	{
			var value = arr[i];

			if(filterArr.indexOf(value) == -1)	{
				filterArr.push(value);
			}

			map[i + 1] = filterArr.length;

			if(line.indexOf(i + 1) > -1)	result.push(map[i + 1]);
		}

		print(result.reverse().join('\n'));

"use strict";

var _slicedToArray = (function() {
  function sliceIterator(arr, i) {
    var _arr = [];
    var _n = true;
    var _d = false;
    var _e = undefined;
    try {
      for (
        var _i = arr[Symbol.iterator](), _s;
        !(_n = (_s = _i.next()).done);
        _n = true
      ) {
        _arr.push(_s.value);
        if (i && _arr.length === i) break;
      }
    } catch (err) {
      _d = true;
      _e = err;
    } finally {
      try {
        if (!_n && _i["return"]) _i["return"]();
      } finally {
        if (_d) throw _e;
      }
    }
    return _arr;
  }
  return function(arr, i) {
    if (Array.isArray(arr)) {
      return arr;
    } else if (Symbol.iterator in Object(arr)) {
      return sliceIterator(arr, i);
    } else {
      throw new TypeError(
        "Invalid attempt to destructure non-iterable instance"
      );
    }
  };
})();

var compose = function compose() {
  for (
    var _len = arguments.length, functions = Array(_len), _key = 0;
    _key < _len;
    _key++
  ) {
    functions[_key] = arguments[_key];
  }

  return function() {
    for (
      var _len2 = arguments.length, args = Array(_len2), _key2 = 0;
      _key2 < _len2;
      _key2++
    ) {
      args[_key2] = arguments[_key2];
    }

    return functions.reduce(function(currArgs, func) {
      return func(currArgs);
    }, args);
  };
};

var lineToNumberArray = function lineToNumberArray(str) {
  return str.split(" ").map(function(num) {
    return parseInt(num, 10);
  });
};

var readNumbersLine = compose(
  readline,
  lineToNumberArray
);

var _readNumbersLine = readNumbersLine(),
  _readNumbersLine2 = _slicedToArray(_readNumbersLine, 2),
  n = _readNumbersLine2[0],
  m = _readNumbersLine2[1];

var arr = readNumbersLine();
var numbers = [];
for (var i = 0; i < m; i++) {
  var number = readNumbersLine();
  numbers.push(number);
}

var map = Object.create(null);
var count = [];

var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;

try {
  for (
    var _iterator = arr.entries()[Symbol.iterator](), _step;
    !(_iteratorNormalCompletion = (_step = _iterator.next()).done);
    _iteratorNormalCompletion = true
  ) {
    var _ref = _step.value;

    var _ref2 = _slicedToArray(_ref, 2),
      key = _ref2[0],
      value = _ref2[1];

    map[value] = map[value] ? map[value] + 1 : 1;
    count[key] = Object.keys(map).length;
  }
} catch (err) {
  _didIteratorError = true;
  _iteratorError = err;
} finally {
  try {
    if (!_iteratorNormalCompletion && _iterator.return) {
      _iterator.return();
    }
  } finally {
    if (_didIteratorError) {
      throw _iteratorError;
    }
  }
}

numbers.forEach(function(pos) {
  var res = count[count.length - 1] - (count[pos - 2] | 0);
  print(res);
});

!function(t){var n={};function r(e){if(n[e])return n[e].exports;var o=n[e]={i:e,l:!1,exports:{}};return t[e].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=t,r.c=n,r.d=function(t,n,e){r.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:e})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,n){if(1&n&&(t=r(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var e=Object.create(null);if(r.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var o in t)r.d(e,o,function(n){return t[n]}.bind(null,o));return e},r.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(n,"a",n),n},r.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},r.p="",r(r.s=42)}([function(t,n,r){var e=r(23)("wks"),o=r(11),i=r(1).Symbol,u="function"==typeof i;(t.exports=function(t){return e[t]||(e[t]=u&&i[t]||(u?i:o)("Symbol."+t))}).store=e},function(t,n){var r=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=r)},function(t,n){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,n,r){t.exports=!r(12)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,n,r){var e=r(5),o=r(15);t.exports=r(3)?function(t,n,r){return e.f(t,n,o(1,r))}:function(t,n,r){return t[n]=r,t}},function(t,n,r){var e=r(6),o=r(25),i=r(27),u=Object.defineProperty;n.f=r(3)?Object.defineProperty:function(t,n,r){if(e(t),n=i(n,!0),e(r),o)try{return u(t,n,r)}catch(t){}if("get"in r||"set"in r)throw TypeError("Accessors not supported!");return"value"in r&&(t[n]=r.value),t}},function(t,n,r){var e=r(2);t.exports=function(t){if(!e(t))throw TypeError(t+" is not an object!");return t}},function(t,n,r){var e=r(1),o=r(4),i=r(8),u=r(11)("src"),c=Function.toString,f=(""+c).split("toString");r(9).inspectSource=function(t){return c.call(t)},(t.exports=function(t,n,r,c){var s="function"==typeof r;s&&(i(r,"name")||o(r,"name",n)),t[n]!==r&&(s&&(i(r,u)||o(r,u,t[n]?""+t[n]:f.join(String(n)))),t===e?t[n]=r:c?t[n]?t[n]=r:o(t,n,r):(delete t[n],o(t,n,r)))})(Function.prototype,"toString",function(){return"function"==typeof this&&this[u]||c.call(this)})},function(t,n){var r={}.hasOwnProperty;t.exports=function(t,n){return r.call(t,n)}},function(t,n){var r=t.exports={version:"2.5.7"};"number"==typeof __e&&(__e=r)},function(t,n){t.exports={}},function(t,n){var r=0,e=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++r+e).toString(36))}},function(t,n){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,n,r){var e=r(44),o=r(16);t.exports=function(t){return e(o(t))}},function(t,n,r){var e=r(45);t.exports=function(t,n,r){if(e(t),void 0===n)return t;switch(r){case 1:return function(r){return t.call(n,r)};case 2:return function(r,e){return t.call(n,r,e)};case 3:return function(r,e,o){return t.call(n,r,e,o)}}return function(){return t.apply(n,arguments)}}},function(t,n){t.exports=function(t,n){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:n}}},function(t,n){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on  "+t);return t}},function(t,n,r){"use strict";var e=r(24),o=r(30),i=r(7),u=r(4),c=r(10),f=r(46),s=r(20),a=r(52),p=r(0)("iterator"),l=!([].keys&&"next"in[].keys()),v=function(){return this};t.exports=function(t,n,r,y,h,d,_){f(r,n,y);var g,x,b,S=function(t){if(!l&&t in w)return w[t];switch(t){case"keys":case"values":return function(){return new r(this,t)}}return function(){return new r(this,t)}},m=n+" Iterator",O="values"==h,j=!1,w=t.prototype,E=w[p]||w["@@iterator"]||h&&w[h],T=E||S(h),M=h?O?S("entries"):T:void 0,P="Array"==n&&w.entries||E;if(P&&(b=a(P.call(new t)))!==Object.prototype&&b.next&&(s(b,m,!0),e||"function"==typeof b[p]||u(b,p,v)),O&&E&&"values"!==E.name&&(j=!0,T=function(){return E.call(this)}),e&&!_||!l&&!j&&w[p]||u(w,p,T),c[n]=T,c[m]=v,h)if(g={values:O?T:S("values"),keys:d?T:S("keys"),entries:M},_)for(x in g)x in w||i(w,x,g[x]);else o(o.P+o.F*(l||j),n,g);return g}},function(t,n){var r=Math.ceil,e=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?e:r)(t)}},function(t,n,r){var e=r(23)("keys"),o=r(11);t.exports=function(t){return e[t]||(e[t]=o(t))}},function(t,n,r){var e=r(5).f,o=r(8),i=r(0)("toStringTag");t.exports=function(t,n,r){t&&!o(t=r?t:t.prototype,i)&&e(t,i,{configurable:!0,value:n})}},function(t,n,r){for(var e=r(22),o=r(32),i=r(7),u=r(1),c=r(4),f=r(10),s=r(0),a=s("iterator"),p=s("toStringTag"),l=f.Array,v={CSSRuleList:!0,CSSStyleDeclaration:!1,CSSValueList:!1,ClientRectList:!1,DOMRectList:!1,DOMStringList:!1,DOMTokenList:!0,DataTransferItemList:!1,FileList:!1,HTMLAllCollection:!1,HTMLCollection:!1,HTMLFormElement:!1,HTMLSelectElement:!1,MediaList:!0,MimeTypeArray:!1,NamedNodeMap:!1,NodeList:!0,PaintRequestList:!1,Plugin:!1,PluginArray:!1,SVGLengthList:!1,SVGNumberList:!1,SVGPathSegList:!1,SVGPointList:!1,SVGStringList:!1,SVGTransformList:!1,SourceBufferList:!1,StyleSheetList:!0,TextTrackCueList:!1,TextTrackList:!1,TouchList:!1},y=o(v),h=0;h<y.length;h++){var d,_=y[h],g=v[_],x=u[_],b=x&&x.prototype;if(b&&(b[a]||c(b,a,l),b[p]||c(b,p,_),f[_]=l,g))for(d in e)b[d]||i(b,d,e[d],!0)}},function(t,n,r){"use strict";var e=r(43),o=r(28),i=r(10),u=r(13);t.exports=r(17)(Array,"Array",function(t,n){this._t=u(t),this._i=0,this._k=n},function(){var t=this._t,n=this._k,r=this._i++;return!t||r>=t.length?(this._t=void 0,o(1)):o(0,"keys"==n?r:"values"==n?t[r]:[r,t[r]])},"values"),i.Arguments=i.Array,e("keys"),e("values"),e("entries")},function(t,n,r){var e=r(9),o=r(1),i=o["__core-js_shared__"]||(o["__core-js_shared__"]={});(t.exports=function(t,n){return i[t]||(i[t]=void 0!==n?n:{})})("versions",[]).push({version:e.version,mode:r(24)?"pure":"global",copyright:"© 2018 Denis Pushkarev (zloirock.ru)"})},function(t,n){t.exports=!1},function(t,n,r){t.exports=!r(3)&&!r(12)(function(){return 7!=Object.defineProperty(r(26)("div"),"a",{get:function(){return 7}}).a})},function(t,n,r){var e=r(2),o=r(1).document,i=e(o)&&e(o.createElement);t.exports=function(t){return i?o.createElement(t):{}}},function(t,n,r){var e=r(2);t.exports=function(t,n){if(!e(t))return t;var r,o;if(n&&"function"==typeof(r=t.toString)&&!e(o=r.call(t)))return o;if("function"==typeof(r=t.valueOf)&&!e(o=r.call(t)))return o;if(!n&&"function"==typeof(r=t.toString)&&!e(o=r.call(t)))return o;throw TypeError("Can't convert object to primitive value")}},function(t,n){t.exports=function(t,n){return{value:n,done:!!t}}},function(t,n){var r={}.toString;t.exports=function(t){return r.call(t).slice(8,-1)}},function(t,n,r){var e=r(1),o=r(9),i=r(4),u=r(7),c=r(14),f=function(t,n,r){var s,a,p,l,v=t&f.F,y=t&f.G,h=t&f.S,d=t&f.P,_=t&f.B,g=y?e:h?e[n]||(e[n]={}):(e[n]||{}).prototype,x=y?o:o[n]||(o[n]={}),b=x.prototype||(x.prototype={});for(s in y&&(r=n),r)p=((a=!v&&g&&void 0!==g[s])?g:r)[s],l=_&&a?c(p,e):d&&"function"==typeof p?c(Function.call,p):p,g&&u(g,s,p,t&f.U),x[s]!=p&&i(x,s,l),d&&b[s]!=p&&(b[s]=p)};e.core=o,f.F=1,f.G=2,f.S=4,f.P=8,f.B=16,f.W=32,f.U=64,f.R=128,t.exports=f},function(t,n,r){var e=r(6),o=r(47),i=r(34),u=r(19)("IE_PROTO"),c=function(){},f=function(){var t,n=r(26)("iframe"),e=i.length;for(n.style.display="none",r(51).appendChild(n),n.src="javascript:",(t=n.contentWindow.document).open(),t.write("<script>document.F=Object<\/script>"),t.close(),f=t.F;e--;)delete f.prototype[i[e]];return f()};t.exports=Object.create||function(t,n){var r;return null!==t?(c.prototype=e(t),r=new c,c.prototype=null,r[u]=t):r=f(),void 0===n?r:o(r,n)}},function(t,n,r){var e=r(48),o=r(34);t.exports=Object.keys||function(t){return e(t,o)}},function(t,n,r){var e=r(18),o=Math.min;t.exports=function(t){return t>0?o(e(t),9007199254740991):0}},function(t,n){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(t,n,r){"use strict";var e=r(54),o=r(41);t.exports=r(59)("Map",function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0)}},{get:function(t){var n=e.getEntry(o(this,"Map"),t);return n&&n.v},set:function(t,n){return e.def(o(this,"Map"),0===t?0:t,n)}},e,!0)},function(t,n,r){var e=r(7);t.exports=function(t,n,r){for(var o in n)e(t,o,n[o],r);return t}},function(t,n){t.exports=function(t,n,r,e){if(!(t instanceof n)||void 0!==e&&e in t)throw TypeError(r+": incorrect invocation!");return t}},function(t,n,r){var e=r(14),o=r(55),i=r(56),u=r(6),c=r(33),f=r(57),s={},a={};(n=t.exports=function(t,n,r,p,l){var v,y,h,d,_=l?function(){return t}:f(t),g=e(r,p,n?2:1),x=0;if("function"!=typeof _)throw TypeError(t+" is not iterable!");if(i(_)){for(v=c(t.length);v>x;x++)if((d=n?g(u(y=t[x])[0],y[1]):g(t[x]))===s||d===a)return d}else for(h=_.call(t);!(y=h.next()).done;)if((d=o(h,g,y.value,n))===s||d===a)return d}).BREAK=s,n.RETURN=a},function(t,n,r){var e=r(29),o=r(0)("toStringTag"),i="Arguments"==e(function(){return arguments}());t.exports=function(t){var n,r,u;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(r=function(t,n){try{return t[n]}catch(t){}}(n=Object(t),o))?r:i?e(n):"Object"==(u=e(n))&&"function"==typeof n.callee?"Arguments":u}},function(t,n,r){var e=r(11)("meta"),o=r(2),i=r(8),u=r(5).f,c=0,f=Object.isExtensible||function(){return!0},s=!r(12)(function(){return f(Object.preventExtensions({}))}),a=function(t){u(t,e,{value:{i:"O"+ ++c,w:{}}})},p=t.exports={KEY:e,NEED:!1,fastKey:function(t,n){if(!o(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!i(t,e)){if(!f(t))return"F";if(!n)return"E";a(t)}return t[e].i},getWeak:function(t,n){if(!i(t,e)){if(!f(t))return!0;if(!n)return!1;a(t)}return t[e].w},onFreeze:function(t){return s&&p.NEED&&f(t)&&!i(t,e)&&a(t),t}}},function(t,n,r){var e=r(2);t.exports=function(t,n){if(!e(t)||t._t!==n)throw TypeError("Incompatible receiver, "+n+" required!");return t}},function(t,n,r){"use strict";r(21),r(22),r(35),r(65);var e=new Map([[1,2],[2,2]]);print(e.get(0)),print(e.get(1))},function(t,n,r){var e=r(0)("unscopables"),o=Array.prototype;void 0==o[e]&&r(4)(o,e,{}),t.exports=function(t){o[e][t]=!0}},function(t,n,r){var e=r(29);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==e(t)?t.split(""):Object(t)}},function(t,n){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,n,r){"use strict";var e=r(31),o=r(15),i=r(20),u={};r(4)(u,r(0)("iterator"),function(){return this}),t.exports=function(t,n,r){t.prototype=e(u,{next:o(1,r)}),i(t,n+" Iterator")}},function(t,n,r){var e=r(5),o=r(6),i=r(32);t.exports=r(3)?Object.defineProperties:function(t,n){o(t);for(var r,u=i(n),c=u.length,f=0;c>f;)e.f(t,r=u[f++],n[r]);return t}},function(t,n,r){var e=r(8),o=r(13),i=r(49)(!1),u=r(19)("IE_PROTO");t.exports=function(t,n){var r,c=o(t),f=0,s=[];for(r in c)r!=u&&e(c,r)&&s.push(r);for(;n.length>f;)e(c,r=n[f++])&&(~i(s,r)||s.push(r));return s}},function(t,n,r){var e=r(13),o=r(33),i=r(50);t.exports=function(t){return function(n,r,u){var c,f=e(n),s=o(f.length),a=i(u,s);if(t&&r!=r){for(;s>a;)if((c=f[a++])!=c)return!0}else for(;s>a;a++)if((t||a in f)&&f[a]===r)return t||a||0;return!t&&-1}}},function(t,n,r){var e=r(18),o=Math.max,i=Math.min;t.exports=function(t,n){return(t=e(t))<0?o(t+n,0):i(t,n)}},function(t,n,r){var e=r(1).document;t.exports=e&&e.documentElement},function(t,n,r){var e=r(8),o=r(53),i=r(19)("IE_PROTO"),u=Object.prototype;t.exports=Object.getPrototypeOf||function(t){return t=o(t),e(t,i)?t[i]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?u:null}},function(t,n,r){var e=r(16);t.exports=function(t){return Object(e(t))}},function(t,n,r){"use strict";var e=r(5).f,o=r(31),i=r(36),u=r(14),c=r(37),f=r(38),s=r(17),a=r(28),p=r(58),l=r(3),v=r(40).fastKey,y=r(41),h=l?"_s":"size",d=function(t,n){var r,e=v(n);if("F"!==e)return t._i[e];for(r=t._f;r;r=r.n)if(r.k==n)return r};t.exports={getConstructor:function(t,n,r,s){var a=t(function(t,e){c(t,a,n,"_i"),t._t=n,t._i=o(null),t._f=void 0,t._l=void 0,t[h]=0,void 0!=e&&f(e,r,t[s],t)});return i(a.prototype,{clear:function(){for(var t=y(this,n),r=t._i,e=t._f;e;e=e.n)e.r=!0,e.p&&(e.p=e.p.n=void 0),delete r[e.i];t._f=t._l=void 0,t[h]=0},delete:function(t){var r=y(this,n),e=d(r,t);if(e){var o=e.n,i=e.p;delete r._i[e.i],e.r=!0,i&&(i.n=o),o&&(o.p=i),r._f==e&&(r._f=o),r._l==e&&(r._l=i),r[h]--}return!!e},forEach:function(t){y(this,n);for(var r,e=u(t,arguments.length>1?arguments[1]:void 0,3);r=r?r.n:this._f;)for(e(r.v,r.k,this);r&&r.r;)r=r.p},has:function(t){return!!d(y(this,n),t)}}),l&&e(a.prototype,"size",{get:function(){return y(this,n)[h]}}),a},def:function(t,n,r){var e,o,i=d(t,n);return i?i.v=r:(t._l=i={i:o=v(n,!0),k:n,v:r,p:e=t._l,n:void 0,r:!1},t._f||(t._f=i),e&&(e.n=i),t[h]++,"F"!==o&&(t._i[o]=i)),t},getEntry:d,setStrong:function(t,n,r){s(t,n,function(t,r){this._t=y(t,n),this._k=r,this._l=void 0},function(){for(var t=this._k,n=this._l;n&&n.r;)n=n.p;return this._t&&(this._l=n=n?n.n:this._t._f)?a(0,"keys"==t?n.k:"values"==t?n.v:[n.k,n.v]):(this._t=void 0,a(1))},r?"entries":"values",!r,!0),p(n)}}},function(t,n,r){var e=r(6);t.exports=function(t,n,r,o){try{return o?n(e(r)[0],r[1]):n(r)}catch(n){var i=t.return;throw void 0!==i&&e(i.call(t)),n}}},function(t,n,r){var e=r(10),o=r(0)("iterator"),i=Array.prototype;t.exports=function(t){return void 0!==t&&(e.Array===t||i[o]===t)}},function(t,n,r){var e=r(39),o=r(0)("iterator"),i=r(10);t.exports=r(9).getIteratorMethod=function(t){if(void 0!=t)return t[o]||t["@@iterator"]||i[e(t)]}},function(t,n,r){"use strict";var e=r(1),o=r(5),i=r(3),u=r(0)("species");t.exports=function(t){var n=e[t];i&&n&&!n[u]&&o.f(n,u,{configurable:!0,get:function(){return this}})}},function(t,n,r){"use strict";var e=r(1),o=r(30),i=r(7),u=r(36),c=r(40),f=r(38),s=r(37),a=r(2),p=r(12),l=r(60),v=r(20),y=r(61);t.exports=function(t,n,r,h,d,_){var g=e[t],x=g,b=d?"set":"add",S=x&&x.prototype,m={},O=function(t){var n=S[t];i(S,t,"delete"==t?function(t){return!(_&&!a(t))&&n.call(this,0===t?0:t)}:"has"==t?function(t){return!(_&&!a(t))&&n.call(this,0===t?0:t)}:"get"==t?function(t){return _&&!a(t)?void 0:n.call(this,0===t?0:t)}:"add"==t?function(t){return n.call(this,0===t?0:t),this}:function(t,r){return n.call(this,0===t?0:t,r),this})};if("function"==typeof x&&(_||S.forEach&&!p(function(){(new x).entries().next()}))){var j=new x,w=j[b](_?{}:-0,1)!=j,E=p(function(){j.has(1)}),T=l(function(t){new x(t)}),M=!_&&p(function(){for(var t=new x,n=5;n--;)t[b](n,n);return!t.has(-0)});T||((x=n(function(n,r){s(n,x,t);var e=y(new g,n,x);return void 0!=r&&f(r,d,e[b],e),e})).prototype=S,S.constructor=x),(E||M)&&(O("delete"),O("has"),d&&O("get")),(M||w)&&O(b),_&&S.clear&&delete S.clear}else x=h.getConstructor(n,t,d,b),u(x.prototype,r),c.NEED=!0;return v(x,t),m[t]=x,o(o.G+o.W+o.F*(x!=g),m),_||h.setStrong(x,t,d),x}},function(t,n,r){var e=r(0)("iterator"),o=!1;try{var i=[7][e]();i.return=function(){o=!0},Array.from(i,function(){throw 2})}catch(t){}t.exports=function(t,n){if(!n&&!o)return!1;var r=!1;try{var i=[7],u=i[e]();u.next=function(){return{done:r=!0}},i[e]=function(){return u},t(i)}catch(t){}return r}},function(t,n,r){var e=r(2),o=r(62).set;t.exports=function(t,n,r){var i,u=n.constructor;return u!==r&&"function"==typeof u&&(i=u.prototype)!==r.prototype&&e(i)&&o&&o(t,i),t}},function(t,n,r){var e=r(2),o=r(6),i=function(t,n){if(o(t),!e(n)&&null!==n)throw TypeError(n+": can't set as prototype!")};t.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(t,n,e){try{(e=r(14)(Function.call,r(63).f(Object.prototype,"__proto__").set,2))(t,[]),n=!(t instanceof Array)}catch(t){n=!0}return function(t,r){return i(t,r),n?t.__proto__=r:e(t,r),t}}({},!1):void 0),check:i}},function(t,n,r){var e=r(64),o=r(15),i=r(13),u=r(27),c=r(8),f=r(25),s=Object.getOwnPropertyDescriptor;n.f=r(3)?s:function(t,n){if(t=i(t),n=u(n,!0),f)try{return s(t,n)}catch(t){}if(c(t,n))return o(!e.f.call(t,n),t[n])}},function(t,n){n.f={}.propertyIsEnumerable},function(t,n,r){r(66),r(67),r(21),r(35),t.exports=r(9).Map},function(t,n,r){"use strict";var e=r(39),o={};o[r(0)("toStringTag")]="z",o+""!="[object z]"&&r(7)(Object.prototype,"toString",function(){return"[object "+e(this)+"]"},!0)},function(t,n,r){"use strict";var e=r(68)(!0);r(17)(String,"String",function(t){this._t=String(t),this._i=0},function(){var t,n=this._t,r=this._i;return r>=n.length?{value:void 0,done:!0}:(t=e(n,r),this._i+=t.length,{value:t,done:!1})})},function(t,n,r){var e=r(18),o=r(16);t.exports=function(t){return function(n,r){var i,u,c=String(o(n)),f=e(r),s=c.length;return f<0||f>=s?t?"":void 0:(i=c.charCodeAt(f))<55296||i>56319||f+1===s||(u=c.charCodeAt(f+1))<56320||u>57343?t?c.charAt(f):i:t?c.slice(f,f+2):u-56320+(i-55296<<10)+65536}}}]);

"use strict";

var _slicedToArray = (function() {
  function sliceIterator(arr, i) {
    var _arr = [];
    var _n = true;
    var _d = false;
    var _e = undefined;
    try {
      for (
        var _i = arr[Symbol.iterator](), _s;
        !(_n = (_s = _i.next()).done);
        _n = true
      ) {
        _arr.push(_s.value);
        if (i && _arr.length === i) break;
      }
    } catch (err) {
      _d = true;
      _e = err;
    } finally {
      try {
        if (!_n && _i["return"]) _i["return"]();
      } finally {
        if (_d) throw _e;
      }
    }
    return _arr;
  }
  return function(arr, i) {
    if (Array.isArray(arr)) {
      return arr;
    } else if (Symbol.iterator in Object(arr)) {
      return sliceIterator(arr, i);
    } else {
      throw new TypeError(
        "Invalid attempt to destructure non-iterable instance"
      );
    }
  };
})();

var compose = function compose() {
  for (
    var _len = arguments.length, functions = Array(_len), _key = 0;
    _key < _len;
    _key++
  ) {
    functions[_key] = arguments[_key];
  }

  return function() {
    for (
      var _len2 = arguments.length, args = Array(_len2), _key2 = 0;
      _key2 < _len2;
      _key2++
    ) {
      args[_key2] = arguments[_key2];
    }

    return functions.reduce(function(currArgs, func) {
      return func(currArgs);
    }, args);
  };
};

var lineToNumberArray = function lineToNumberArray(str) {
  return str.split(" ").map(function(num) {
    return parseInt(num, 10);
  });
};

var readNumbersLine = compose(
  readline,
  lineToNumberArray
);

var _readNumbersLine = readNumbersLine(),
  _readNumbersLine2 = _slicedToArray(_readNumbersLine, 2),
  n = _readNumbersLine2[0],
  m = _readNumbersLine2[1];

var arr = readNumbersLine();
var numbers = [];
for (var i = 0; i < m; i++) {
  var number = readNumbersLine();
  numbers.push(number);
}

var map = Object.create(null);
var count = [];

var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;

try {
  for (
    var _iterator = arr.entries()[Symbol.iterator](), _step;
    !(_iteratorNormalCompletion = (_step = _iterator.next()).done);
    _iteratorNormalCompletion = true
  ) {
    var _ref = _step.value;

    var _ref2 = _slicedToArray(_ref, 2),
      key = _ref2[0],
      value = _ref2[1];

    map[value] = map[value] ? map[value] + 1 : 1;
    count[key] = Object.keys(map).length;
  }
} catch (err) {
  _didIteratorError = true;
  _iteratorError = err;
} finally {
  try {
    if (!_iteratorNormalCompletion && _iterator.return) {
      _iterator.return();
    }
  } finally {
    if (_didIteratorError) {
      throw _iteratorError;
    }
  }
}

numbers.forEach(function(pos) {
  var posOutside = pos - 2;
  var res = count[count.length - 1] - (posOutside < 0 ? 0 : count[posOutside]);
  print(res);
});

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

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

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

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

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

Input

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

Output

6
6
6
6
6
5
4
3
2
1
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let lenthOfInput = Number(inputString[0].split(" ")[0]);
    let lengthOfLocations = Number(inputString[0].split(" ")[1]);
    let input = inputString[1].split(" ");
    let locations = inputString.slice(2, 12);

    solution(lenthOfInput, lengthOfLocations, input, locations);
});

function solution(lenthOfInput, lengthOfLocations, input, locations) {

    let solutionArray = [];
    let frequencyMap = {};
    let perfixSumForDistinct = [];

    for (let index = lenthOfInput - 1; index > -1; index--) {

        if (!frequencyMap[input[index]]) {

            if (index)
                perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] ? perfixSumForDistinct[index + 1] + 1 : 1

            else
                perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] ? perfixSumForDistinct[index + 1] + 1 : 1
        }

        if (frequencyMap[input[index]]) {
            perfixSumForDistinct[index] = perfixSumForDistinct[index + 1]
        }

        frequencyMap[input[index]] = 1;
    }

    console.log(perfixSumForDistinct);

    for (let index = 0; index < lengthOfLocations; index++) {
        let solution = perfixSumForDistinct[locations[index] - 1]
        solutionArray.push(solution);
        solutionArray.push("\n")
    }

    console.log(solutionArray.join(""));

}

'use strict';

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    // console.log("input ",inputString.slice(2,inputString.length));
    distinctNumbers(inputString[0], inputString[1], inputString.slice(2, inputString.length));
});
function distinctNumbers(nm, values, nums) {
    values = values.split(" ");
    var freqArr = {};
    var perfixSum = [];
    var distincts = 0;
    for (let i = 0; i < values.length; i++) {
        if (!freqArr[values[i]]) {
            freqArr[values[i]] = 1;
            distincts += 1;
        }
        else {
            freqArr[values[i]] += 1;
        }
    }
    for (let i = 0; i < values.length; i++) {
        perfixSum.push( distincts);
        perfixSum.push( "\n");
        if (freqArr[values[i]] == 1)
            distincts -= 1;
        else {
            freqArr[values[i]] -= 1
        }
    }
        console.log(perfixSum.join(""));

}
// distinctNumbers('10 10', '1 2 3 4 1 2 3 4 100000 99999', '1 2 3 4 5 6 7 8 9 10')'

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

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

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

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

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

Input

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

Output

6
6
6
6
6
5
4
3
2
1
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let lenthOfInput = Number(inputString[0].split(" ")[0]);
    let lengthOfLocations = Number(inputString[0].split(" ")[1]);
    let input = inputString[1].split(" ");
    let locations = inputString.slice(2, 12);

    if (lenthOfInput == 81220) {
        console.log(input);
        console.log(locations);
    }
    solution(lenthOfInput, lengthOfLocations, input, locations);
});

function solution(lenthOfInput, lengthOfLocations, input, locations) {

    let solutionArray = [];
    let frequencyMap = {};
    let perfixSumForDistinct = [];

    for (let index = lenthOfInput - 1; index > -1; index--) {

        if (!frequencyMap[input[index]]) {

            if (index)
                perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] ? perfixSumForDistinct[index + 1] + 1 : 1

            else
                perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] ? perfixSumForDistinct[index + 1] + 1 : 1
        }

        if (frequencyMap[input[index]]) {
            perfixSumForDistinct[index] = perfixSumForDistinct[index + 1]
        }

        frequencyMap[input[index]] = 1;
    }

    for (let index = 0; index < lengthOfLocations; index++) {
        let solution = perfixSumForDistinct[locations[index] - 1]
        solutionArray.push(solution);
        solutionArray.push("\n")
    }

    console.log(solutionArray.join(""));

}

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

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

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

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

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

Input

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

Output

6
6
6
6
6
5
4
3
2
1
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let lenthOfInput = Number(inputString[0].split(" ")[0]);
    let lengthOfLocations = Number(inputString[0].split(" ")[1]);
    let input = inputString[1].split(" ");
    let locations = inputString.slice(2, 12);

    solution(lenthOfInput, lengthOfLocations, input, locations);
});

function solution(lenthOfInput, lengthOfLocations, input, locations) {

    let solutionArray = [];
    let frequencyMap = {};
    let perfixSumForDistinct = [];

    for (let index = lenthOfInput - 1; index > -1; index--) {

        if (!frequencyMap[input[index]]) {

            if (index)
                perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] ? perfixSumForDistinct[index + 1] + 1 : 1

            else
                perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] + 1
        }

        if (frequencyMap[input[index]]) {
            perfixSumForDistinct[index] = perfixSumForDistinct[index + 1]
        }

        frequencyMap[input[index]] = 1;
    }

    for (let index = 0; index < lengthOfLocations; index++) {
        let solution = perfixSumForDistinct[index]
        solutionArray.push(solution);
        solutionArray.push("\n")
    }

    console.log(solutionArray.join(""));

}

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

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

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

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

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

Input

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

Output

6
6
6
6
6
5
4
3
2
1
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let lenthOfInput = Number(inputString[0].split(" ")[0]);
    let lengthOfLocations = Number(inputString[0].split(" ")[1]);
    let input = inputString[1].split(" ");
    let locations = inputString.slice(2, 12);

    solution(lenthOfInput, lengthOfLocations, input, locations);
});

function solution(lenthOfInput, lengthOfLocations, input, locations) {

    let solutionArray = [];
    let frequencyMap = {};
    let perfixSumForDistinct = [];

    for (let index = lenthOfInput - 1; index > -1; index--) {

        if (!frequencyMap[input[index]]) {

            if (index)
                perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] ? perfixSumForDistinct[index + 1] + 1 : 1

            else
                perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] ? perfixSumForDistinct[index + 1] + 1 : 1
        }

        if (frequencyMap[input[index]]) {
            perfixSumForDistinct[index] = perfixSumForDistinct[index + 1]
        }

        frequencyMap[input[index]] = 1;
    }

    for (let index = 0; index < lengthOfLocations; index++) {
        let solution = perfixSumForDistinct[locations[index] - 1]
        solutionArray.push(solution);
        solutionArray.push("\n")
    }

    console.log(solutionArray.join(""));

}

 'use strict';

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    // console.log("input ",inputString.slice(2,inputString.length));
    distinctNumbers(inputString[1], inputString.slice(2, inputString.length));
});

function distinctNumbers(values, nums) {
    values = values.split(" ");
    var freqArr = {};
    var perfixSum = [];
    var distincts = 0;
    for (let i = 0; i < values.length; i++) {
        if (!freqArr[values[i]]) {
            freqArr[values[i]] = 1;
            distincts += 1;
        } else {
            freqArr[values[i]] += 1;
        }
    }
    for (let i = 0; i < values.length; i++) {
        perfixSum[i] = distincts;
        perfixSum.push("\n")
        if (freqArr[values[i]] == 1)
            distincts -= 1;
        else {
            freqArr[values[i]] -= 1
        }
    }
        console.log(perfixSum.join(""));

}
// distinctNumbers('10 10', '1 2 3 4 1 2 3 4 100000 99999', '1 2 3 4 5 6 7 8 9 10')'

'use strict';

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    // console.log("input ",inputString.slice(2,inputString.length));
    distinctNumbers(inputString[0], inputString[1], inputString.slice(2, inputString.length));
});
function distinctNumbers(nm, values, nums) {
    values = values.split(" ");
    var freqArr = {};
    var perfixSum = [];
    var sol = []
    var distincts = 0;
    for (let i = 0; i < values.length; i++) {
        if (!freqArr[values[i]]) {
            freqArr[values[i]] = 1;
            distincts += 1;
        }
        else {
            freqArr[values[i]] += 1;
        }
    }
    for (let i = 0; i < values.length; i++) {
        perfixSum.push( distincts);
        perfixSum.push( "\n");
        if (freqArr[values[i]] == 1)
            distincts -= 1;
        else {
            freqArr[values[i]] -= 1
        }
    }

    for(let i = 0 ; i <nums.length ; i++){
       sol.push(perfixSum[Number(nums[i] - 1 )])
       sol.push("\n")
    }

        console.log(perfixSum.join(""));

}
// distinctNumbers('10 10', '1 2 3 4 1 2 3 4 100000 99999', '1 2 3 4 5 6 7 8 9 10')'

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

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

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

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

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

Input

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

Output

6
6
6
6
6
5
4
3
2
1
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let lenthOfInput = Number(inputString[0].split(" ")[0]);
    let lengthOfLocations = Number(inputString[0].split(" ")[1]);
    let input = inputString[1].split(" ");
    let locations = inputString.slice(2, 12);

    console.log(input);
    console.log(locations);

    solution(lenthOfInput, lengthOfLocations, input, locations);
});

function solution(lenthOfInput, lengthOfLocations, input, locations) {

    let solutionArray = [];
    let frequencyMap = {};
    let perfixSumForDistinct = [];

    for (let index = lenthOfInput - 1; index > -1; index--) {

        if (!frequencyMap[input[index]]) {

            if (index)
                perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] ? perfixSumForDistinct[index + 1] + 1 : 1

            else
                perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] ? perfixSumForDistinct[index + 1] + 1 : 1
        }

        if (frequencyMap[input[index]]) {
            perfixSumForDistinct[index] = perfixSumForDistinct[index + 1]
        }

        frequencyMap[input[index]] = 1;
    }

    for (let index = 0; index < lengthOfLocations; index++) {
        let solution = perfixSumForDistinct[locations[index] - 1]
        solutionArray.push(solution);
        solutionArray.push("\n")
    }

    console.log(solutionArray.join(""));

}

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

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

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

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

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

Input

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

Output

6
6
6
6
6
5
4
3
2
1
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let lenthOfInput = Number(inputString[0].split(" ")[0]);
    let lengthOfLocations = Number(inputString[0].split(" ")[1]);
    let input = inputString[1].split(" ");
    let locations = inputString.slice(2, 12);

    if (lenthOfInput == 81220) {
        console.log(locations);
    }
    solution(lenthOfInput, lengthOfLocations, input, locations);
});

function solution(lenthOfInput, lengthOfLocations, input, locations) {

    let solutionArray = [];
    let frequencyMap = {};
    let perfixSumForDistinct = [];

    for (let index = lenthOfInput - 1; index > -1; index--) {

        if (!frequencyMap[input[index]]) {

            if (index)
                perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] ? perfixSumForDistinct[index + 1] + 1 : 1

            else
                perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] ? perfixSumForDistinct[index + 1] + 1 : 1
        }

        if (frequencyMap[input[index]]) {
            perfixSumForDistinct[index] = perfixSumForDistinct[index + 1]
        }

        frequencyMap[input[index]] = 1;
    }

    for (let index = 0; index < lengthOfLocations; index++) {
        let solution = perfixSumForDistinct[locations[index] - 1]
        solutionArray.push(solution);
        solutionArray.push("\n")
    }

    console.log(solutionArray.join(""));

}

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

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

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

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

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

Input

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

Output

6
6
6
6
6
5
4
3
2
1
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let lenthOfInput = Number(inputString[0].split(" ")[0]);
    let lengthOfLocations = Number(inputString[0].split(" ")[1]);
    let input = inputString[1].split(" ");
    let locations = inputString.slice(2, 12);

    solution(lenthOfInput, lengthOfLocations, input, locations);
});

function solution(lenthOfInput, lengthOfLocations, input, locations) {

    let solutionArray = [];
    let frequencyMap = {};
    let perfixSumForDistinct = [];

    for (let index = lenthOfInput - 1; index > -1; index--) {

        if (!frequencyMap[input[index]]) {

            if (index)
                perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] ? perfixSumForDistinct[index + 1] + 1 : 1

            else
                perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] + 1
        }

        if (frequencyMap[input[index]]) {
            perfixSumForDistinct[index] = perfixSumForDistinct[index + 1]
        }

        frequencyMap[input[index]] = 1;
    }

    for (let index = 0; index < lengthOfLocations; index++) {
        let solution = perfixSumForDistinct[locations[index] - 1]
        solutionArray.push(solution);
        solutionArray.push("\n")
    }

    console.log(solutionArray.join(""));

}

const input = [];

const RL = require('readline').createInterface({
   input : process.stdin,
   output : process.stdout
});

RL.on('line', line => input.push(line));

RL.on('close', () => {
  const [n, m] = input[0].split(' ').map(x => parseInt(x));
  const nums = input[1].split(' ').map(x => parseInt(x));

  const map = {}; const data = []; let cnt = 0;
  for (let i = nums.length - 1; i >= 0; i -= 1) {
    let x = nums[i];
    if (map[x] === undefined) { cnt += 1; map[x] = true; }
    data[i] = cnt;
  }

  const answer = [];
  for (let i = 0; i < m; i += 1) {
    let x = parseInt(input[i+2]);
    answer.push(data[x]);
  }

  console.log(answer.join("\n"))
});

const input = [];

const RL = require('readline').createInterface({
   input : process.stdin,
   output : process.stdout
});

RL.on('line', line => input.push(line));

RL.on('close', () => {
  const [n, m] = input[0].split(' ').map(x => parseInt(x));
  const nums = input[1].split(' ').map(x => parseInt(x));

  const map = {}; const data = []; let cnt = 0;
  for (let i = nums.length - 1; i >= 0; i -= 1) {
    let x = nums[i];
    if (map[x] === undefined) { cnt += 1; map[x] = true; }
    data[i] = cnt;
  }

  const answer = [];
  for (let i = 0; i < m; i += 1) {
    let x = parseInt(input[i+2]);
    answer.push(data[x]);
    if (i + 1 < m)
      answer.push('\n');
  }

  console.log(answer.join(""))
});

'use strict';

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    distinctNumbers(inputString[0], inputString[1],inputString[2]);
});
function distinctNumbers(nm, values, nums) {
    var values = values.split(" ");
    var nums = nums.split(" ");
    var freqArr = {};
    var perfixSum = [];
    var distincts = 0;
    // for(let i = 0; i < values.length; i++)
    for (let i = 0; i < values.length; i++) {
        var val = values[i];
        if (!freqArr[val]) {
            freqArr[val] = 1;
            distincts += 1;
            // perfixSum[i] = i == 0 ? 1 : perfixSum[i - 1] + 1;
        }
        else {
            // perfixSum[i] = i > 0 ? perfixSum[i - 1] : 1;
            freqArr[val] += 1;
        }
    }
    for(let i = 0; i < values.length; i++){
        var val = values[i];
        perfixSum[i] = distincts;
        if(freqArr[val] == 1)
        distincts -=1;
        else{
            freqArr[val] -=1
        }
    }
    for(let i = 0; i <nums.length;i++){
        var index =  parseInt(nums[i]) -1;
        console.log(perfixSum[index]);

    }
    // console.log("perf ",perfixSum);

}
// distinctNumbers('10 10', '1 2 3 4 1 2 3 4 100000 99999', '1 2 3 4 5 6 7 8 9 10')

'use strict';

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    distinctNumbers(inputString[0], inputString[1],inputString[2]);
});
function distinctNumbers(nm, values, nums) {
    values = values.split(" ");
    nums = nums.split(" ");
    nm = nm.split(" ");
    var  numsLen = nm[1];
    var freqArr = {};
    var perfixSum = [];
    var distincts = 0;
    // for(let i = 0; i < values.length; i++)
    for (let i = 0; i < values.length; i++) {
        var val = values[i];
        if (!freqArr[val]) {
            freqArr[val] = 1;
            distincts += 1;
            // perfixSum[i] = i == 0 ? 1 : perfixSum[i - 1] + 1;
        }
        else {
            // perfixSum[i] = i > 0 ? perfixSum[i - 1] : 1;
            freqArr[val] += 1;
        }
    }
    for(let i = 0; i < values.length; i++){
        var val = values[i];
        perfixSum[i] = distincts;
        if(freqArr[val] == 1)
        distincts -=1;
        else{
            freqArr[val] -=1
        }
    }
    for(let i = 0; i <numsLen;i++){
        var index =  parseInt(nums[i]) -1;
        console.log(perfixSum[index]);

    }
    // console.log("perf ",perfixSum);

}
// distinctNumbers('10 10', '1 2 3 4 1 2 3 4 100000 99999', '1 2 3 4 5 6 7 8 9 10')

'use strict';

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    distinctNumbers(inputString[0], inputString[1],inputString[2]);
});
function distinctNumbers(nm, values, nums) {
    var values = values.split(" ");
    var nums = nums.split(" ");
    var freqArr = {};
    var perfixSum = [];
    var distincts = 0;
    // for(let i = 0; i < values.length; i++)
    for (let i = 0; i < values.length; i++) {
        var val = values[i];
        if (!freqArr[val]) {
            freqArr[val] = 1;
            distincts += 1;
            // perfixSum[i] = i == 0 ? 1 : perfixSum[i - 1] + 1;
        }
        else {
            // perfixSum[i] = i > 0 ? perfixSum[i - 1] : 1;
            freqArr[val] += 1;
        }
    }
    for(let i = 0; i < values.length; i++){
        var val = values[i];
        perfixSum[i] = distincts;
        if(freqArr[val] == 1)
        distincts -=1;
        else{
            freqArr[val] -=1
        }
    }
    for(let i = 0; i <nums.length;i++){
        var index =  nums[i] -1;
        console.log(perfixSum[index]);

    }
    // console.log("perf ",perfixSum);

}
// distinctNumbers('8 3', '8 6 4 3 4 2 4 8', '6 4 2')

'use strict';

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    distinctNumbers(inputString[0], inputString[1],inputString[2]);
});
function distinctNumbers(nm, values, nums) {
    var values = values.split(" ");
    var nums = nums.split(" ");
    var freqArr = {};
    var perfixSum = [];
    var distincts = 0;
    // for(let i = 0; i < values.length; i++)
    for (let i = 0; i < values.length; i++) {
        var val = values[i];
        if (!freqArr[val]) {
            freqArr[val] = 1;
            distincts += 1;
            perfixSum[i] = i == 0 ? 1 : perfixSum[i - 1] + 1;
        }
        else {
            perfixSum[i] = i > 0 ? perfixSum[i - 1] : 1;
            freqArr[val] += 1;
        }
    }
    var lastCount = 0;
    for (let i = 0; i < perfixSum.length; i++) {
        if (lastCount == perfixSum[i]) {
            console.log(distincts);
            distincts = distincts - 1;
        }
        else
            console.log(distincts);
        lastCount = perfixSum[i];
    }
}
// distinctNumbers('10 10', '1 2 3 4 1 2 3 4 100000 99999', '1 2 3 4 5 6 7 8 9 10')

'use strict';

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    let valuesLen = Number(inputString[0].split(" ")[0]);
    let numLen = Number(inputString[0].split(" ")[1]);
    let values = inputString[1].split(" ");
    let nums = inputString.slice(2);
    distinctNumbers(valuesLen, numLen, values, nums);
});
function distinctNumbers(valuesLen, numLen, values, nums) {
    var freqArr = {};
    var perfixSum = [];
    var distincts = 0;
    for (let i = 0; i < valuesLen; i++) {
        if (!freqArr[values[i]]) {
            freqArr[values[i]] = 1;
            distincts++;
        }
        else {
            freqArr[values[i]]++;
        }
    }
    for (let i = 0; i < valuesLen; i++) {
        perfixSum[i] = distincts;
        if (freqArr[values[i]] == 1)
            distincts--;
        else {
            freqArr[values[i]]--
        }
        if(nums[i])
        console.log(perfixSum[Number(nums[i]) - 1]);

    }
    // for (let i = 0; i < numLen; i++) {
    // }
}

'use strict';

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    distinctNumbers(inputString[0], inputString[1],inputString[2]);
});
function distinctNumbers(nm, values, nums) {
    var values = values.split(" ");
    var nums = nums.split(" ");
    var freqArr = {};
    var perfixSum = [];
    var distincts = 0;
    // for(let i = 0; i < values.length; i++)
    for (let i = 0; i < values.length; i++) {
        var val = values[i];
        if (!freqArr[val]) {
            freqArr[val] = 1;
            distincts += 1;
            // perfixSum[i] = i == 0 ? 1 : perfixSum[i - 1] + 1;
        }
        else {
            // perfixSum[i] = i > 0 ? perfixSum[i - 1] : 1;
            freqArr[val] += 1;
        }
    }
    for(let i = 0; i < values.length; i++){
        var val = values[i];
        perfixSum[i] = distincts;
        console.log(distincts);

        if(freqArr[val] == 1)
        distincts -=1;
        else{
            freqArr[val] -=1
        }
    }
    // console.log("perf ",perfixSum);

}
// distinctNumbers('10 10', '1 2 3 4 1 2 3 4 100000 99999', '1 2 3 4 5 6 7 8 9 10')


var a = [];

    function check(n, m, k) {
        var index = 0;
        var limit = Math.min(k, Math.floor(n/2));
        var total = n;
        var record = [];
        while (total > 0 && index < limit) {
            if (total == 1) {
                if (record[0] > 2) {
                    record[0]--;
                    total++;
                }
            }
            var rows = Math.floor(a[index] / m);
            total -= rows;
            record.push(rows);
            index++;
            if (rows < 2) {
                break;
            }
        }
        return total <= 0;
    }

    var tests = parseInt(readline());
    for (var t=0; t < tests; t++) {
        var nmk = readline().split(' ').map(x=>parseInt(x));
        var n = nmk[0];
        var m = nmk[1];
        var k = nmk[2];
        a = readline().split(' ').map(x=>parseInt(x));
        a.sort((x, y) => y-x);
        if (check(n, m, k) || check(m, n, k)) {
            print('Yes');
        } else {
            print('No');
        }
    }

"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");

function print(x) {
    console.log(x);
}

let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
    inputString += inputStdin;
});
process.stdin.on("end", () => {
    inputString = inputString.split("\n");
    main();
});

function readline() {
    return inputString[currentLine++];
}

function readNumbersLine() {
    return readline().split(" ").map(el => +el);
}

function solve() {
    let [n, m, k] = readNumbersLine()

    let A = readNumbersLine()
    let startSum = n * m

    if (n > m) {
        [n, m] = [m, n]
    }

    A.sort((a, b) => a - b)
    let [n2, m2] = [n, m]

    for (let i = 0; i < A.length; i++) {
        if (Math.floor(A[i] / n) >= 2) {
            m = m - Math.floor(A[i] / n)
        }
        if (m === 1) {
            if (Math.floor(A[i] / n) > 2) {
                m += 1
            } else {
                m += 2
            }
        }
        if (m <= 0) {
            console.log("YES")
            return
        }
    }

    for (let i = 0; i < A.length; i++) {
        if (Math.floor(A[i] / m2) >= 2) {
            n2 = n2 - Math.floor(A[i] / m2)
        }
        if (n2 === 1) {
            if (Math.floor(A[i] / m2) > 2) {
                n2 += 1
            } else {
                n2 += 2
            }
        }
        if (n2 <= 0) {
            console.log("YES")
            return
        }
    }

    console.log("NO");
    return;

}

function main() {
    let k = +readline()
    for (let i = 0; i < k; i++) {
        solve();
    }

}


'use strict';

function solve(n, a, s) {
  let res = 1n;
  a = a.map(num => num - 1);
  const st = new Array(n);
  for (let i = 0; i < n; i++) {
    if (i === a[i] || st[i]) continue;
    const query = [i];
    for (let j of query) {
      st[j] = 1;
      if (a[j] === i) break;
      query.push(a[j]);
    }
    let str = query.map(i => s[i]).join('');
    if (new Set(str).size === 1) continue;
    const change = BigInt(kmp(str + str, str));
    res = res * change / gcd(res, change);
  }
  return res.toString();
}
function gcd(a, b) {
  return b ? gcd(b, a % b) : a;
}
function kmp(source, p) {
  if (p === '') return 0;
  const next = new Array(p.length).fill(0);
  for (let l = 0, r = 1; r < p.length; r++) {
    while (l > 0 && p[l] !== p[r]) l = next[l - 1];
    if (p[l] === p[r]) next[r] = ++l;
  }
  for (let i = 1, j = 0; i < source.length; i++) {
    while (j > 0 && source[i] !== p[j]) j = next[j - 1];
    if (source[i] === p[j]) j++;
    if (j === p.length) return i - j + 1;
  }
  return -1;
}

async function main(read) {
  try {
    let res = [];
    let t = Number(await read());
    while (t--) {
      const n = Number(await read());
      const s = await read();
      const a = (await read()).split(' ').map(Number);
      res.push(solve(n, a, s));
    }
    console.log(res.join('\n'));
  } catch (error) {
    console.log(error);
  }
}

let inputs,
    str = '';
function read() {
  return inputs.next().value.trim();
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', input => str += input);
process.stdin.on('end', () => {
  inputs = str.split('\n').values();
  main(read);
});

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const n = +lines[l++]
        const str = lines[l++]
        const arr = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(n, str, arr)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, str, arr) {
    const adj = {}
    for (let i = 0; i < arr.length; i++) {
        const a = i
        const b = arr[i] - 1
        adj[a] = adj[a] || []
        adj[a].push(b)
    }
    //
    const visited = {}
    let ans = 1n
    for (let i = 0; i < arr.length; i++) {
        if (visited[i]) continue
        const now = dfs(adj, i, visited)

        // let k = 0
        // const base = []
        // now.forEach(x => base[x] = str[x])
        // let prev = base
        // while (k < now.length) {
        //     k++
        //     const dp = []
        //     let same = true
        //     for (let j = 0; j < now.length; j++) {
        //         const x = now[j]
        //         dp[x] = prev[adj[x][0]]
        //         if (dp[x] !== base[x]) {
        //             same = false
        //             // break
        //         }
        //     }
        //     if (same) break
        //     prev = dp
        // }
        const base = now.map(x => str[x]).join('')
        let k = kmp(base + base, base)
        k = BigInt(k)
        const g = gcd(ans, k)
        ans *= k / g
        // console.log(now, k)
    }
    return ans
}
function kmp(source, p) {
  if (p === '') return 0;
  const next = new Array(p.length).fill(0);
  for (let l = 0, r = 1; r < p.length; r++) {
    while (l > 0 && p[l] !== p[r]) l = next[l - 1];
    if (p[l] === p[r]) next[r] = ++l;
  }
  // hack as from 1
  for (let i = 1, j = 0; i < source.length; i++) {
    while (j > 0 && source[i] !== p[j]) j = next[j - 1];
    if (source[i] === p[j]) j++;
    if (j === p.length) return i - j + 1;
  }
  return -1;
}
function dfs(adj, r, visited) {
    const stack = [[r, 0, -1]]
    const now = []
    while (stack.length) {
        const [u, i, p] = stack[stack.length - 1]
        visited[u] = 1

        const nb = adj[u] || []
        if (!i) {
            // first visited
            now.push(u)
        }
        if (i < nb.length) {
            stack[stack.length - 1][1]++
            const v = nb[i]
            if (!visited[v]) { // has circle
            // if (v !== p) {
                stack.push([v, 0, u])
            }
        } else {
            // last visited
            stack.pop()
        }
    }
    return now
}
function gcd(a, b) {
    if (a === 0n) return b
    if (b === 0n) return a

    while (a) {
        const r = b % a
        b = a
        a = r
    }
    return b
}

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const n = +lines[l++]
        const str = lines[l++]
        const arr = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(n, str, arr)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, str, arr) {
    const adj = {}
    for (let i = 0; i < arr.length; i++) {
        const a = i
        const b = arr[i] - 1
        adj[a] = adj[a] || []
        adj[a].push(b)
    }
    //
    const visited = {}
    let ans = 1n
    for (let i = 0; i < arr.length; i++) {
        if (visited[i]) continue
        const now = dfs(adj, i, visited)

        let k = 0
        const base = {}
        now.forEach(x => base[x] = str[x])
        let prev = base
        while (k < now.length) {
            k++
            const dp = {}
            now.forEach(x => dp[x] = prev[adj[x][0]])
            let same = true
            for (let j = 0; j < now.length; j++) {
                if (base[now[j]] !== dp[now[j]]) {
                    same = false
                    break
                }
            }
            if (same) break
            prev = dp
        }
        // let p
        // let same = true
        // for (let j in now) {
        //     k++
        //     const x = str[+j - 1]
        //     if (p && x !== p) same = false
        //     p = x
        // }
        ans *= BigInt(k)
        // console.log(now, k)
    }
    return ans
}
function dfs(adj, r, visited) {
    const stack = [[r, 0, -1]]
    const now = []
    while (stack.length) {
        const [u, i, p] = stack[stack.length - 1]
        visited[u] = 1

        const nb = adj[u] || []
        if (!i) {
            // first visited
            now.push(u)
        }
        if (i < nb.length) {
            stack[stack.length - 1][1]++
            const v = nb[i]
            if (!visited[v]) { // has circle
            // if (v !== p) {
                stack.push([v, 0, u])
            }
        } else {
            // last visited
            stack.pop()
        }
    }
    return now
}

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const n = +lines[l++]
        const str = lines[l++]
        const arr = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(n, str, arr)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, str, arr) {
    const adj = {}
    for (let i = 0; i < arr.length; i++) {
        const a = i + 1
        const b = arr[i]
        adj[a] = adj[a] || []
        adj[a].push(b)
    }
    //
    const visited = {}
    let ans = 1n
    for (let i = 0; i < arr.length; i++) {
        if (visited[i]) continue
        const now = dfs(adj, i, visited)
        let k = 0n
        let p
        let same = true
        for (let j in now) {
            k++
            const x = str[+j - 1]
            if (p && x !== p) same = false
            p = x
        }
        if (!same) ans *= k
        // console.log(now, k, same)
    }
    return ans
}
function dfs(adj, r, visited) {
    const stack = [[r, 0, -1]]
    const now = {}
    while (stack.length) {
        const [u, i, p] = stack[stack.length - 1]
        visited[u] = 1
        now[u] = 1

        const nb = adj[u] || []
        if (!i) {
            // first visited
        }
        if (i < nb.length) {
            stack[stack.length - 1][1]++
            const v = nb[i]
            if (!visited[v]) { // has circle
            // if (v !== p) {
                stack.push([v, 0, u])
            }
        } else {
            // last visited
            stack.pop()
        }
    }
    return now
}


var toInt = x =>parseInt(x);

var t = parseInt(readline());

for(var tt=0;tt<t;tt++) {
    readline();
    var ar = readline().split(' ').map(toInt);

    var visited = {};
    ar = ar.filter(v => {
        var r = visited[v]===undefined;
        visited[v] = true;
        return r;
    });
    print(ar.length);

    // var sorted = ar.map((v,i) => ({v,i})).sort((a, b) =>{
    //     if (a.v===b.v) {
    //         return a.i-b.i;
    //     }
    //     return a.v-b.v;
    // });

    // var r=1;
    // for(var i=1, cycle=0;i<ar.length && cycle<=ar.length; i++) {
    //     if(sorted[i-1].i > sorted[i].i) {
    //         cycle++;
    //         print('c++ ', sorted[i-1].v);
    //     }
    //     print('>',cycle, sorted[i].v);
    //     r++;
    // }
    // print(r);

    // var q = [];
    // ar.forEach( (v,i) => ( q.push({i,v, cycle:0, l:1}) ));
    // var best = 0;
    // while(q.length > 0) {
    //     var cur = q.shift();
    //     best = Math.max(best, cur.l);
    //     if (cur.cycle >= ar.length) break;

    //     for(var i=cur.i+1; i<ar.length; i++) {
    //         if (ar[i] > ar[cur.i]) {
    //             q.push({i, cycle:cur.cycle, l:cur.l+1});
    //         }
    //     }
    //     for(var i=0; i<cur.i; i++) {
    //         if (ar[i] > ar[cur.i]) {
    //             q.push({i, cycle:cur.cycle+1, l:cur.l+1});
    //         }
    //     }
    // }
    // print(best);
}

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    return;
  }

  if (c % 2) {
    c++;
    return;
  }

  const ans = new Set(d.split(' ').map(Number)).size;
  console.log(ans);

  c++;
});

rl.on('close', () => {

});

// Sample code to perform I/O:

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";

process.stdin.on("data", function (input) {
    stdin_input += input;                               // Reading input from STDIN
});

process.stdin.on("end", function () {
    main(stdin_input);
});

function main(input) {
    let output = nameLookUp(input);
    process.stdout.write(output);       // Writing output to STDOUT
}

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail

// Write your code here
function nameLookUp(str) {

    let inputs = str.trim().split('\n');
    let ind = 0;
    let lis = [];
    for (let index = 0; index < +inputs[0]; index++) {

        ind += 2;
        lis.push([... new Set(inputs[ind].trim().split(' '))].length);
    }

    return lis.join('\n').toString();
}

let data = '';
process.stdin.on('data', c => data += c);

const sol = () => {
     nums = data.trim().split(/\n/g);
     let t = Number(nums.shift());
     result = [];
     for(let i = 0; i < t; i += 1 ){
          let n = Number(nums[2 * i]);
          let arr = nums[2 * i + 1].trim().split(/\s+/g).map(Number);
          let s = new Set();
          arr.forEach((e) => {
               s.add(e);
               });
          result.push(s.size);
     }
     console.log(result.join('\n'));
}

process.stdin.on('end', sol);

'use strict'

const getLine = () => readline().split(' ')
const getInts = () => getLine().map(n => parseInt(n))
const getInt = () => getInts()[0]
const D = (...args) => { // D({name})
  [...args].forEach(cur => print.apply(print, [JSON.stringify(cur)]))
}

main()

function main() {
  let t = getInt()
  while (t --> 0) {
    const n = getInt()
    const arr = getInts()
    const st = new Set(arr)
    print(st.size)
  }
}

function readStringArray() {
  return readline().split(" ");
}
function readNumArray() {
  return readStringArray().map(Number);
}

function main() {
  var testCasesNum = +readline();
  for (var i = 0; i < testCasesNum; i++) {
    var n = +readline();
    var arr = readNumArray();
    var s = new Set(arr);
    print(s.size);
  }
}
main()

function compare( a , b){
    return a-b;
}

var t = parseInt(readline());
while(t-- > 0){
    var n = parseInt(readline());
    var arr = readline().split(" ").map( Number );
    var len = arr.length;
    arr.sort(compare);
    var count = 0;
    for(var i = 0 ;i<len-1; i++){
        if(arr[i]!=arr[i+1]){
            count++;
        }
    }
    // if(arr[len-1]!=arr[len-2])
    //     count++;
    print(count+1);
}

var arrLength, arr, arrUniq;
var taskNum = readline();
for (var i = 0; i < taskNum; i++) {
  arrLen = readline();
  arr = readline().split(' ').map(x => parseInt(x));
  arrUniq = new Set(arr);
  print(Math.min(arrLen, arrUniq.size));
}

// input = readline();
var t = parseInt(readline());

while(t-- > 0) {
    var N = parseInt(readline());
    var array = readline().split(' ').map(x => parseInt(x));
    var res = Array.from(new Set(array));
    print(res.length);
}

//var input = readline();
var T = parseInt(readline());

for (var i = 0; i < T; i++) {
    var n = parseInt(readline());
    var ar = readline().split(' ').map(x => parseInt(x));
    var ok = Array.from(new Set(ar));
    print(ok.length);
}

process.stdin.resume();
process.stdin.setEncoding('utf-8')
let inputString = '';
let currentLine = 0;
process.stdin.on('data', input => { inputString += input; })
process.stdin.on('end', _ => { inputString = inputString.split('\n'); main(); })
const readline = () => { return inputString[currentLine++] }

function main() {
    let n = parseInt(readline());
    for (let i = 0; i < n; i++) {
        const len = parseInt(readline());
        const readNumbers = {};
        const uniqueNumber = readline()
          .split(' ')
          .map(line => parseInt(line))
          .reduce((acc, curr) => {
            if (!readNumbers[curr]) {
              readNumbers[curr] = true;
              acc += 1;
            }
            return acc;
          }, 0);

        console.log(uniqueNumber);
    }
}

process.stdin.resume()
process.stdin.setEncoding('utf-8')

let input = ''
let ptr = 0
process.stdin.on('data', (i) => {
  input += i
})

process.stdin.on('end', () => {
  input = input.split('\n').map(a => a.replace(/(\r\n|\n|\r)/gm, ''))
  main()
})

function wr(...x) {
  console.log(...x)
}

function sort(a, inc = true) {
  if(inc) a.sort((a, b) => a - b)
  else a.sort((a, b) => b - a)
}

function readInt() {
  return parseInt(input[ptr++])
}

function readString() {
  return input[ptr++]
}

function readStrings() {
  return input[ptr++].split(' ')
}

function readInts() {
  return input[ptr++].split(' ').map(a => parseInt(a))
}

function main() {
  let t = readInt()
  while(t--) {
    const n = readInt()
    const a = readInts()
    let count = 0
    let map = {}
    for(let i = 0; i < n; i++) {
      if(!map[a[i]]) {
        map[a[i]] = true
        count++
      }
    }
    wr(count)
  }
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n');
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr('time : ' + end + 'ms');
  myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var t = nextInt();
  var output = new Array(t);
  for(var i = 0; i < t; i++){
  	var N = nextInt();
  	var list = nextIntArray();
  	var set = new Set();
  	for(var j = 0; j < N; j++){
  		set.add(list[j]);
  	}
  	output[i] = set.size;
  }
  myout(myconv(output, 9));
}

function compare( a , b){
    return a-b;
}

var t = parseInt(readline());
while(t-- > 0){
    var n = parseInt(readline());
    var arr = readline().split(" ").map( Number );
    var len = arr.length;
    arr.sort(compare);
    var count = 0;
    for(var i = 0 ;i<len-1; i++){
        if(arr[i]!=arr[i+1]){
            count++;
        }
    }
    if(arr[len-1]!=arr[len-2])
        count++;
    print(count);
}

let data = '';
process.stdin.on('data', c => data += c);

const sol = () => {
     nums = data.trim().split(/\n/g);
     let t = Number(nums.shift());
     result = [];
     for(let i = 0; i < t; i += 1 ){
          let n = Number(nums[2 * i]);
          let arr = nums[2 * i + 1].split(/\s+/g).map(Number);
          let s = new Set();
          arr.forEach((e) => {
               s.add(e);
               });
          result.push(s.size);
     }
     console.log(result.join('\n'));
}

process.stdin.on('end', sol);