NumberEater

No attempts yetTime limit1sMemory limit128 MB

Problem

NumberEater is a famous monster from Byteland. It eats numbers, but it is very picky: every day its meal must be unique. The monster is given a sequence of integers a1,a2,,ana_1, a_2, \ldots, a_n. It chooses a start position ii and an end position jj (1ijn1 \le i \le j \le n) and prepares a meal made of the elements ai,ai+1,,aja_i, a_{i+1}, \ldots, a_j.

The monster considers two meals [i1,j1][i_1, j_1] and [i2,j2][i_2, j_2] to be identical when they contain the same set of numbers, that is:

{ak:i1kj1}={ak:i2kj2}\{a_k : i_1 \le k \le j_1\} = \{a_k : i_2 \le k \le j_2\}

Help NumberEater count how many different meals it can prepare using the sequence aa.

Input

The first line contains one integer nn (1n5001 \le n \le 500), the length of the sequence aa. Each of the next nn lines contains one element of the sequence. Every element is at least 11 and at most 500500.

Output

Print a single integer: the number of different meals that NumberEater can prepare.