Sasha and Ira are two best friends. But they aren’t just friends, they are software engineers and experts in artificial intelligence. They are developing an algorithm for two bots playing a two-player game. The game is cooperative and turn based. In each turn, one of the players makes a move (it doesn’t matter which player, it's possible that players turns do not alternate). 

Algorithm for bots that Sasha and Ira are developing works by keeping track of the state the game is in. Each time either bot makes a move, the state changes. And, since the game is very dynamic, it will never go back to the state it was already in at any point in the past.

Sasha and Ira are perfectionists and want their algorithm to have an optimal winning strategy. They have noticed that in the optimal winning strategy, both bots make exactly N moves each. But, in order to find the optimal strategy, their algorithm needs to analyze all possible states of the game (they haven’t learned about alpha-beta pruning yet) and pick the best sequence of moves.

They are worried about the efficiency of their algorithm and are wondering what is the total number of states of the game that need to be analyzed? 


-----Input-----

The first and only line contains integer N.  1 ≤ N ≤ 10^6 


-----Output-----

Output should contain a single integer – number of possible states modulo 10^9 + 7.


-----Examples-----
Input
2

Output
19



-----Note-----

Start: Game is in state A.   Turn 1: Either bot can make a move (first bot is red and second bot is blue), so there are two possible states after the first turn – B and C.  Turn 2: In both states B and C, either bot can again make a turn, so the list of possible states is expanded to include D, E, F and G.  Turn 3: Red bot already did N=2 moves when in state D, so it cannot make any more moves there. It can make moves when in state E, F and G, so states I, K and M are added to the list. Similarly, blue bot cannot make a move when in state G, but can when in D, E and F, so states H, J and L are added.  Turn 4: Red bot already did N=2 moves when in states H, I and K, so it can only make moves when in J, L and M, so states P, R and S are added. Blue bot cannot make a move when in states J, L and M, but only when in H, I and K, so states N, O and Q are added. 

Overall, there are 19 possible states of the game their algorithm needs to analyze.

[Image]

Source: codeforces | Difficulty: MEDIUM_HARD
Tags: Number theory

Combinatorics

Dynamic programming

Mathematics


Solutions:
import sys
import math
MOD = 1000000007

def inv(a, b):
	if a > 1:
		return b - inv(b % a, a) * b // a
	else:
		return 1

def main():
	n = int(sys.stdin.readline().strip())
	t = 1
	m = 1
	for i in range(1, n + 2):
		t = t * (n + i + 1) % MOD
		m = m * i % MOD
	print(t * inv(m, MOD) % MOD - 1)
main()


MOD = 10 ** 9 + 7
fact = [1] * 2000004
for i in range(1, 2000004):
	fact[i] = fact[i - 1] * i % MOD

def C(n, k):
	return fact[n] * pow(fact[k], MOD - 2, MOD) ** 2 % MOD
x = int(input()) + 1
res = C(x * 2, x) - 1
print(res)


import cmath
n = int(input())
q = 1
p = 1

def inv(a, b):
	if a > 1:
		return b - inv(b % a, a) * b // a
	else:
		return 1
for j in range(1, n + 2):
	p = p * (n + 1 + j) % 1000000007
	q = q * j % 1000000007
print(p * inv(q, 1000000007) % 1000000007 - 1)


MOD = 10 ** 9 + 7
x = int(input()) + 1
n = 1
n2 = 1
fac = 1
for i in range(1, 2 * x + 1):
	fac = fac * i % MOD
	if i == x:
		n = fac
	if i == 2 * x:
		n2 = fac
res = n2 * pow(n, MOD - 2, MOD) ** 2 % MOD - 1
print(res)


def f(n, mod=10 ** 9 + 7):
	ans = 1
	for i in range(1, n + 1):
		ans = ans * i % mod
	return ans

def g(n, mod=10 ** 9 + 7):
	num1 = f(n * 2)
	den1 = f(n) ** 2 % mod
	return num1 * pow(den1, mod - 2, mod) % mod
n = int(input()) + 1
print(g(n) - 1)


n = int(input())
(u, v, f, B) = (1, 1, 1, 10 ** 9 + 7)
for i in range(2, n + 2):
	u = u * i % B
for i in range(2, n + n + 3):
	f = f * i % B

def inv(u):
	if u < 2:
		return 1
	return -(B // u) * inv(B % u) % B
print((f * inv(u) * inv(u) + B - 1) % B)