Ensure that you are logged in and have the required permissions to access the test.

Optimistic Permutations

0

0 votes
Problem

Let p1,p2,...,pn be a permutation of 1,2,...,n.

An optimistic permutation follows pi>i2i[1,n].

An over-optimistic permutation has the following properties:

  • It is optimistic.
  • There exists atleast one i(i[1,n]) such that  pii+2.

Given n, find the count of all over-optimistic permutations modulo 109+7.

Input:

The first line contains T - the number of testcases, followed by T lines each containing one integer n.

Output:

For each testcase print the answer on a newline.

Constraints:

  • 1T500000
  • 1n1018
Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

For n=3, the only possible over-optimistic permutation is {3,1,2}.

Editor Image

?