You are given a sequence of length N. Write a program that counts the contiguous intervals in which no value appears twice.
An interval has length at least 1, and two intervals are different when their start or their end differs. In other words, count the pairs (i,j) with 1≤i≤j≤N such that the values from position i to position j are pairwise different.