#P1418G. Three Occurrences
Three Occurrences
No submission language available for this problem.
Description
You are given an array consisting of integers. We denote the subarray as the array ().
A subarray is considered good if every integer that occurs in this subarray occurs there exactly thrice. For example, the array has three good subarrays:
- ;
- ;
- .
Calculate the number of good subarrays of the given array .
The first line contains one integer ().
The second line contains integers , , ..., ().
Print one integer — the number of good subarrays of the array .
Input
The first line contains one integer ().
The second line contains integers , , ..., ().
Output
Print one integer — the number of good subarrays of the array .