시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB76221929.231%

문제

The NumberEater is a famous monster from Byteland. It eats numbers, but it is very picky: each day its meal must be unique. The monster is given a sequence of integers (an). It chooses the starting and ending positions of a meal -i and j (1 ≤ i ≤ j ≤ n) - and prepares a meal that consists of elements ai, ai+1, …, aj. The monster considers two meals [i1,j1] and [i2,j2] identical if the sets of numbers that they contain are the same; in other words:

{ak : i1 ≤ k ≤ j1} = {ak : i2 ≤ k ≤ j2}

Help NumberEater and count the number of different meals that it can prepare using only the sequence a.

입력

The first line of the input contains one integer n (1 ≤ n ≤ 500), the length of the sequence a. The following n lines contain values of elements of the sequence. Each of them is at least 1 and at most 500.

출력

The first and only line of the output should contain the number of different meals that NumberEater can prepare.

 

예제 입력 1

6
1
2
3
1
2
3

예제 출력 1

7

출처

Camp > POI Training Camp > ONTAK 2007 10번