Good subarray - MarisaOJ: Marisa Online Judge

Good subarray

Time limit: 1000 ms
Memory limit: 512 MB
An array $B$ is good if $B$ only consists of consecutive integers when sorted. Given an array $A$ of $n$ integers. Count the number of good subarray in $A$. ### Input - The first line contains an integer $n$. - The next line contains $n$ integers $A_i$. ### Output - Print the number of good subarrays. ### Constraints - $1 \le n \le 10^5$. - $1 \le A_i \le n$. ### Example Input: ``` 3 1 2 3 ``` Output: ``` 6 ```