Loading [MathJax]/jax/output/CommonHTML/jax.js
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 Ai. ### Output - Print the number of good subarrays. ### Constraints - 1≤n≤105. - 1≤Ai≤n. ### Example Input: 3123 Output: 6