import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int arr[] = new int[n];
for(int i= 0;i<n;i++){
arr[i] = sc.nextInt();
}
int x = sumoflength(arr,n);
System.out.print(x);
}
public static int sumoflength(int[] arr, int n)
{
// For maintaining distinct elements.
Set<Integer> s = new HashSet<>();
// Initialize ending point and result
int j = 0, ans = 0;
// Fix starting point
for (int i = 0; i < n; i++)
{
while (j < n && !s.contains(arr[j]))
{
s.add(arr[i]);
j++;
}
// Calculating and adding all possible length
// subarrays in arr[i..j]
ans += ((j - i) * (j - i + 1)) / 2;
// Remove arr[i] as we pick new stating point
// from next
s.remove(arr[i]);
}
return ans;
}
}