OIL
时间限制:C/C++/Rust/Pascal 8秒,其他语言16秒
空间限制:C/C++/Rust/Pascal 1024 M,其他语言2048 M
64bit IO Format: %lld

题目描述



Given a sequence of integers a_1,\dots,a_n , you need to process m operations.
In an operation x , you need to change a_1,a_2,\dots,a_x to a_x,\dots,a_2,a_1 , and then query how many different k satisfies that there exists i,j that 1\le i\le x<j\le n s.t. a_i=a_j=k .
Operations are NOT independent.

There is no 1\le i<j<k<l\le n s.t. a_i=a_j=a_k=a_l
1\le a_i\le n
1\le x\le n
1\le n,m\le 3\times 10^5


输入描述:

The first line contains two integers n,m .
The next line contains n integers a_1,\dots,a_n .
For the next m lines, each line contains an integer x , representing an operation.

输出描述:

For each operation, output an integer in a line representing the answer.
示例1

输入

复制
6 5
4 2 5 5 4 4
2
5
5
3
6

输出

复制
1
1
1
2
0