[BOJ 8529] NumberEater

View as PDF

Submit solution

Points: 2
Time limit: 1.0s
Memory limit: 128M

Problem types
Allowed languages
Assembly, Awk, C, C++, Java, Pascal, Perl, Python, Sed, Text

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:</p>

{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.</p>

 

예제 입력

6
1
2
3
1
2
3

예제 출력

7

Comments

There are no comments at the moment.