LogiQuest

249. Count Binary Search Trees

MediumCatalan

Print the number of structurally different BSTs that store the values 1..n, modulo 10⁹ + 7.

Input format

A single integer n.

Output format

The count mod 10⁹ + 7.

Example 1

Input

3

Output

5

Example 2

Input

1

Output

1

Constraints

1 ≤ n ≤ 1000

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

Loading the MyLoginn IDE…