United Cows of Farmer John
문제
The United Cows of Farmer John (UCFJ) are sending a delegation to the International bOvine olympIad (IOI).
There are cows participating in delegation selection (). They are standing in a line, and cow has breed .
The delegation will consist of a contiguous interval of at least two cows - that is, cows for integers and satisfying . The two outermost cows of the chosen interval will be designated as "leaders." To avoid intra-breed conflict, every leader must be of a different breed from the rest of the delegation (leaders or not).
Help the UCFJ determine (for tax reasons) the number of ways they might choose a delegation to send to the IOI.
입력
The first line contains .
The second line contains integers , each in the range .
출력
The number of possible delegations, on a single line.
Note that the large size of integers involved in this problem may require the use of 64-bit integer data types (e.g., a "long long" in C/C++).
힌트
Each delegation corresponds to one of the following pairs of leaders:
예제
예제 1
7 1 2 3 4 3 2 5
13