SubArrays with Distinct elements STL problem

I didn’t understand the problem. please explain
Given an array, the task is to calculate the sum of lengths of contiguous subarrays having all elements distinct

Input Format:
An integer n denoting size of array followed by n integers

Constraints:
1<=N<=10^5

Output Format
The answer mod 10^9+7

Sample Input
3
1 2 3
Sample Output
10

let say we have an array A and with indexes from i to j we have all distinct elements.
Here j is the maximum of all the indexes which satisfy the condition.
than total number of subarray with distinct elements starting from i are (j-i)(j-i+1)/2;
ie let the length of the subarray be n.
all subarrays with
1 element are n.
2 element are n-1.
3 element are n-2.
.
.
.
.
n element are 1.
adding we have n(n+1)/2

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.