Beauty Values
题号:NC51560
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld

题目描述

Gromah and LZR have entered the second level. There is a sequence  on the wall.


There is also a note board saying "the beauty value of a sequence is the number of different elements in the sequence".

LZR soon comes up with the password of this level, which is the sum of the beauty values of all successive subintervals of the sequence on the wall.

Please help them determine the password!


输入描述:

The first line contains one positive integer , denoting the length of the sequence.

The second line contains positive integers , denoting the sequence.


输出描述:

Print a non-negative integer in a single line, denoting the answer.
示例1

输入

复制
4
1 2 1 3

输出

复制
18

说明

The beauty values of subintervals [1,1], [2,2], [3,3], [4,4]_{} are all 1_{}.
The beauty values of subintervals [1,2], [1,3], [2,3], [3,4]_{} are all 2_{}.
The beauty values of subintervals [1,4], [2,4]_{} are all 3_{}.
As a result, the sum of all beauty values are 1\times 4 + 2\times 4 + 3\times 2 = 18.