Lucru mare-i omenia

Time limit: 1s Memory limit: 256MB Input: Output:

"În viață câștigi sau pierzi
Omenia s-o păstrezi, măi"

A trader keeps a daily log of trading results. Each day is recorded as either a winning day (W) or a losing day (L). Over a period of 2N2N trading days, the trader records exactly NN winning days and NN losing days.

A winning streak is any non-empty contiguous subsequence of days such that every day in that interval is a win (W). Two streaks are considered different if they correspond to different intervals.

Task

Compute the total sum of winning streaks over all valid sequences, modulo 109+710^9 + 7.

Formally, let A\mathcal{A} be the set of all sequences of length 2N2N containing exactly NN characters W and NN characters L. Then the answer is:

(aA  1i2N  ij2N  fa(i,j))mod(109+7)\left( \sum_{a \in \mathcal{A}} \;\sum_{1 \le i \le 2N} \;\sum_{i \le j \le 2N} \;\text{f}_a(i, j) \right) \bmod (10^9 + 7)

where

fa(i,j)={1,if a[i]=a[i+1]==a[j]=W,0,otherwise.\text{f}_a(i, j) = \begin{cases} 1, & \text{if } a[i] = a[i+1] = \dots = a[j] = \texttt{W}, \\\\ 0, & \text{otherwise.} \end{cases}

Input data

The first line of the input contains a single integer TT, representing the number of queries.

Each of the next TT lines contains a single integer NN.

Output data

For each query, output a single line containing the answer corresponding to that value of NN, modulo 109+710^9 + 7.

Constraints and clarifications

  • 1T1051 \leq T \leq 10^5
  • 1N1061 \leq N \leq 10^6

Example

stdin

2
1
2

stdout

2
15

Explanation

For N=1N = 1, the possible sequences are:

  • WL 1\rightarrow 1 streak
  • LW 1\rightarrow 1 streak

Total: 22

For N=2N = 2, all sequences and their number of winning streaks:

  • WWLL 3\rightarrow 3
  • WLWL 2\rightarrow 2
  • WLLW 2\rightarrow 2
  • LWWL 3\rightarrow 3
  • LWLW 2\rightarrow 2
  • LLWW 3\rightarrow 3

Total: 1515

Log in or sign up to be able to send submissions!