시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
5 초 512 MB 19 11 9 52.941%

## 문제

A necklace composed of n beads is given, where each bead is one of k possible kinds. The beads are numbered with integers from 1 to n. The bead no. i is adjacent to (in fact, between) the beads no. i + 1 and i − 1 (if these beads exist); moreover, the beads no. 1 and n are also adjacent. We would like to partition the necklace by two cuts into two non-empty parts (strings) so that each kind of bead occurs in exactly one part (i.e., if one part contains a bead of kind j, then the other has no bead of this kind). How many such partition are there and what is the minimum difference of lengths of the two resulting parts?

## 입력

The first line of the standard input contains two integers, n and k (2 ≤ k ≤ n ≤ 1 000 000), separated by a single space, that specify the length of the necklace and the number of bead kinds. The latter are numbered from 1 to k. The second line of input contains a sequence of n integers, r1, r2, . . . , rn (1 ≤ ri ≤ k), separated by single spaces; the number ri specifies the kind of bead no. i. You may assume that each kind of bead occurs in the necklace.

In tests worth 30% of the total score, the additional condition n ≤ 1000 holds.

## 출력

The first and only line of the standard input should contain two integers separated by a single space. The first of these numbers should be the number of valid partitions of the necklace (you may assume that at least one exists for the input data). The second number should be the minimum difference in lengths of the resulting parts.

## 예제 입력 1

9 5
2 5 3 2 2 4 1 1 3


## 예제 출력 1

4 3


## 힌트

There are four valid partitions; the shorter of the resulting parts can contain either of the following bead kinds: (5), (4), (1, 1), or (4, 1, 1). The last option gives rise to the optimal length difference of 6 − 3 = 3.