LogiQuest

240. Number of Longest Increasing Subsequences

HardDynamic Programming

Print how many strictly increasing subsequences have the maximum possible length.

Input format

Line 1: n Line 2: n integers

Output format

The count.

Example 1

Input

5
1 3 5 4 7

Output

2

Example 2

Input

5
2 2 2 2 2

Output

5

Constraints

1 ≤ n ≤ 2000

Read input from standard input and print the answer to standard output. Your code is judged against 6 test cases, most of them hidden.

Loading the MyLoginn IDE…