Subarrays with distinct elements

i am applying the same logc as told by sir n hint video but i am getting wrong output

hello @ayu2321
image

it should be (j-i) *(j-i+1)/2

can you please explain the logic behind this formula used by sir

let say we have found subarray of length L with all elements distinct.

now if i pick any subarray from this L length subarray then that will also contain all distinct elements .

so total how many subarray possible in this L length subarray.
it will be L * (L+1)/2 ( LC2 + L )