CRDS - Cards

Maricruz have a lot of cards, she always uses her cards to build pyramids as shown in the following image:

Cards

A pyramid card of 3 levels. She always wonder how many cards does she need to make a pyramid card of N levels. Your task is to answer that question.

Input

The first line of the input contains an integer 1 <= T <= 1,000. Each of the following T lines will have an integer 1 <= N <= 1,000,000.

Output

For each case, output a single line consisting of the number of cards needed to build a pyramid card of level N modulo 1,000,007.

Example

Input Example
2
3
7

Output Example
15
77

Added by:Paulo Costa
Date:2012-01-30
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:UGTO

hide comments
2016-05-27 15:41:10
use long long int in place of of int
costed me 3 WA
2016-05-08 12:40:56
thanks tony t
2016-04-24 08:45:18
Arithmetic Progression :)
2016-04-02 09:55:05
What is the meaning of this lines:
For each case, output a single line consisting of the number of cards needed to
build a pyramid card of level N modulo 1,000,007.
2016-03-13 13:11:07
Easiest problem in SPOJ...AC in one go :-)
2016-03-04 06:50:48 Arnabjyoti Kalita
Very easy.. just take care of the datatypes :)
2016-02-04 12:11:33 Pranay Kumar
Too easy!!
Move to tutorials!!!!
2016-02-01 22:12:51 ayush sinha
useless question
2016-01-17 09:56:37
2 WA because question is not clear;
remember if f(n) is the real ans, modulo is not f(n%1000007), its f(n)%1000007
2016-01-04 18:56:37
DP solution is acceptable but why not evaluate the formula.
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.