Phone Network
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

In M Country, there are cities and these cities are placed in one line, where the cities are labeled one by one. Citizens in M Country all use MI-phones, and there are totally m network modes among the MI-phones. For better management, MI-phones in i-th city can only use A_i-th mode.

As a MI fan, you want to experience all kind of network modes. So for each , you want to find a shortest subinterval in M Country that all network modes from to are used at least once among the cities whose labels are in interval , and we denote l_i as the length of the shortest subinterval. In this problem, you need to determine .

输入描述:

The first line contains two integers .

The second line contains integers .

It's guaranteed that for each integer between and , it appears in sequence at least once.

输出描述:

Only one line containing  integers .
示例1

输入

复制
5 3
1 3 2 3 1

输出

复制
1 3 3

说明

For i = 1_{}, [1]_{} contains all network modes from 1_{} to 1_{}.

For i = 2_{}, [1,3,2]_{} contains all network modes from 1_{} to 2_{}.

For i = 3_{}, [2,3,1]_{} contains all network modes from 1_{} to 3_{}.