#K6766. Count Special Sequences
Count Special Sequences
Count Special Sequences
Given an array of positive integers, a special sequence is defined as a contiguous subarray whose elements can be rearranged to form a strictly increasing sequence. Equivalently, the subarray must consist of distinct elements.
Your task is to count the total number of such special sequences in the given array.
Constraints:
- 1 ≤ n ≤ 105
- Each element is a positive integer.
inputFormat
The input is read from standard input (stdin) and has the following format:
The first line contains an integer n, the length of the array. The second line contains n space-separated positive integers representing the elements of the array.
outputFormat
Output a single integer to standard output (stdout) – the total number of special sequences (i.e. contiguous subarrays with all distinct elements).
## sample3
1 2 3
6