An integer M and a non-empty null-indexed array A consisting of N are non-negative integers. All integers in array A are less than or equal to M.
A pair of integers (P, Q), such that 0 ≤ P ≤ Q <N, is called a slice of array A. A slice consists of elements A [P], A [P + 1], ..., A [Q]. A different slice is a slice consisting only of unique numbers. That is, no individual number is found more than once in a slice.
For example, consider an integer M = 6 and an array A such that:
A[0] = 3
A[1] = 4
A[2] = 5
A[3] = 5
A[4] = 2
There are exactly nine different sections: (0, 0), (0, 1), (0, 2), (1, 1), (1,2), (2, 2), (3, 3), (3 , 4) and (4, 4).
The goal is to calculate the number of individual slices.