#include <stdio.h>
#include <algorithm>

using namespace std;

int main() {
	int en, ep;
	scanf("%d%d", &en, &ep);

	int arr[100001];
	long long sum = 0;
	for (int i = 0; i < en; i++) {
		scanf("%d", &arr[i]);
		sum += arr[i];
	}

	int ans;
	long long left = 0;
	for (int i = 0; i < en - 1; i++) {
		left += arr[i];
		long long right = sum - left;
		ans = max(ans, (int)(left % ep + right % ep));
	}
	printf("%d", ans);

	return 0;
}


#include <stdio.h>
#include <algorithm>

using namespace std;

int main() {
	int en, ep;
	scanf("%d%d", &en, &ep);

	int arr[100001];
	int sum = 0;
	for (int i = 0; i < en; i++) {
		scanf("%d", &arr[i]);
		sum += arr[i];
	}

	int ans;
	int left = 0;
	for (int i = 0; i < en - 1; i++) {
		left += arr[i];
		int right = sum - left;
		ans = max(ans, left % ep + right % ep);
	}
	printf("%d", ans);

	return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define pi 3.14
using namespace std;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef pair<long long,int> pli;
typedef pair<int,long long> pil;
const int INF=1000000007;
const int MOD=998244353;
const int nmax=101234;

int n,p,res,a[nmax];

int main()
{
    scanf("%d%d",&n,&p);
    for(int i=0;i<n;++i)
        scanf("%d",&a[i]);
    int tmp=0;
    for(int i=0;i<n;++i)
        tmp=(tmp+a[i])%p;
    int tmp2=0;
    for(int i=0;i+1<n;++i){
        tmp=(tmp-a[i]+p)%p;
        tmp2=(tmp2+a[i])%p;
        if(tmp+tmp2>res)
            res=tmp+tmp2;
    }
    printf("%d\n",res);
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define pi 3.14
using namespace std;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef pair<long long,int> pli;
typedef pair<int,long long> pil;
const int INF=1000000007;
const int MOD=998244353;
const int nmax=101234;

int n,p,res,a[nmax];

int main()
{
    scanf("%d%d",&n,&p);
    for(int i=0;i<n;++i){
        scanf("%d",&a[i]);
        a[i]%=p;
    }
    int tmp=0;
    for(int i=0;i<n;++i)
        tmp=(tmp+a[i])%p;
    int tmp2=0;
    for(int i=0;i+1<n;++i){
        tmp=(tmp-a[i]+p)%p;
        tmp2=(tmp2+a[i])%p;
        if(tmp+tmp2>res)
            res=tmp+tmp2;
    }
    printf("%d\n",res);
    return 0;
}


import java.util.*;

public class Main {

    private static final long MOD = 1000000007;

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        long[] arr = new long[2000001];
        arr[3] = 4;

        for(int i=4;i<=2000000;i++) {
            arr[i] = (2*arr[i-2]) + arr[i-1];
            arr[i] = (arr[i]+(i % 3 == 0 ? 4 : 0)) % MOD;
        }

        int t = scan.nextInt();

        while (t-- >0 ) {
            int n = scan.nextInt();

            System.out.println(arr[n]);
        }

    }

}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class d {

	public static void main(String[] args) throws Exception {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		sc = new FastScanner(in);
		int t = sc.nextInt();
		int max = 2000001;
		long mod = 1000000007;

		long[][] dp = new long[max][4];
		dp[1][0] = 1;
		for (int i = 2; i < max; i++) {
			dp[i][2] = (dp[i - 1][2]%mod + dp[i - 1][1]%mod)%mod;
			dp[i][1] = dp[i - 1][0]%mod;
			dp[i][0] = ((dp[i - 1][1]%mod * 2)%mod + dp[i - 1][0]%mod)%mod;

			dp[i][3] = (( i-3>=0 ? dp[i - 3][3]:0) %mod + dp[i - 1][1]%mod)%mod;

		}
		long[] as = new long[max];

		while (t-- > 0) {

			int n = sc.nextInt();
			if(n==1 || n==2) {
				out.println(0);
				continue;
			}
			out.println(((dp[n][3]% mod) * 4L) % mod);
		}

		out.flush();

	}

	static BufferedReader in;
	static FastScanner sc;
	static PrintWriter out;

	static class FastScanner {
		BufferedReader in;
		StringTokenizer st;

		public FastScanner(BufferedReader in) {
			this.in = in;
		}

		public String nextToken() throws Exception {
			while (st == null || !st.hasMoreTokens()) {
				st = new StringTokenizer(in.readLine());
			}
			return st.nextToken();
		}

		public int nextInt() throws Exception {
			return Integer.parseInt(nextToken());
		}

		public long nextLong() throws Exception {
			return Long.parseLong(nextToken());
		}

		public double nextDouble() throws Exception {
			return Double.parseDouble(nextToken());
		}
	}
}


    import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
	static ArrayList<Integer> adj[];

	static int k;
	static int[] a;
	static int b[];
	static int m;

	static class Pair implements Comparable<Pair> {
		int c;
		int d;
		public Pair(int b, int l) {
			c = b;
			d = l;
		}
		@Override
		public int compareTo(Pair o) {
		return o.d-this.d;
		}

	}

	static ArrayList<Pair> adjlist[];
	// static char c[];
	static long mod = (long) (1e9 + 7);
	static int V;
	static long INF = (long) 1E16;
	static int n;
	static char c[];
	static Pair p[];
static long grid[][];
static Scanner sc = new Scanner(System.in);
static PrintWriter out = new PrintWriter(System.out);
public static void main(String args[]) throws Exception {
	int t=sc.nextInt();
	long dp[]=new long[(int) (2e6+5)];
	dp[3]=4;
	for (int i = 4; i < dp.length; i++) {
		long z=dp[i-1]+dp[i-2]*2;
		z%=mod;
		if(i%3==0)
			z+=4;
		z%=mod;
		dp[i]=z;
	}
	while(t-->0) {
		int n=sc.nextInt();
		System.out.println(dp[n]);
	}
}
static int[] compreessarray(int c[]) {
	Stack<Integer> st=new Stack<>();
	for (int i = 0; i < c.length; i++) {
		if(st.isEmpty()||c[i]!=st.peek())
		st.add(c[i]);
	}
	b=new int[st.size()];
	for (int i = b.length-1; i>=0; i--) {
		b[i]=st.pop();
	}
	return b;
}
static int div4[];
static long [] reversearray(long a[]) {
	for (int i = 0; i <a.length/2; i++) {
		long temp=a[i];
		a[i]=a[a.length-i-1];
		a[a.length-i-1]=temp;
	}
	return a;
}
static int [] reversearray(int a[]) {
	for (int i = 0; i <=a.length/2; i++) {
		int temp=a[i];
		a[i]=a[a.length-i-1];
		a[a.length-i-1]=temp;
	}
	return a;
}
static  TreeSet<Integer> ts=new TreeSet();
static HashMap<Integer, Integer> compress(int a[]) {
		 ts = new TreeSet<>();
		HashMap<Integer, Integer> hm = new HashMap<>();
		for (int x : a)
			ts.add(x);
		for (int x : ts) {
			hm.put(x, hm.size() + 1);
		}
		return hm;
	}

	static  class FenwickTree { // one-based DS

		int n;
		int[] ft;

		FenwickTree(int size) { n = size; ft = new int[n+1]; }

		int rsq(int b) //O(log n)
		{
			int sum = 0;
			while(b > 0) { sum += ft[b]; b -= b & -b;}		//min?
			return sum;
		}

		int rsq(int a, int b) { return rsq(b) - rsq(a-1); }

		void point_update(int k, int val)	//O(log n), update = increment
		{
			while(k <= n) { ft[k] += val; k += k & -k; }		//min?
		}
	}
	static ArrayList<Integer> euler=new ArrayList<>();

	static ArrayList<Integer> arr;

static int[] total;
static TreeMap<Integer,Integer> map1;

		static int zz;
//static int dp(int idx,int left,int state) {
//if(idx>=k-((zz-left)*2)||idx+1==n) {
//	return 0;
//}
//if(memo[idx][left][state]!=-1) {
//	return memo[idx][left][state];
//}
//int ans=a[idx+1]+dp(idx+1,left,0);
//if(left>0&&state==0&&idx>0) {
//	ans=Math.max(ans,a[idx-1]+dp(idx-1,left-1,1));
//}
//return memo[idx][left][state]=ans;
//}21
static HashMap<Integer,Integer> map;
static int maxa=0;
static int ff=123123;

static int[][] memo;

	static long modmod=998244353;
	static int dx[]= {1,-1,0,0};
	 static int dy[]= {0,0,1,-1};
	static class BBOOK implements Comparable<BBOOK>{
		int t;
		int alice;
		int bob;
		public BBOOK(int x,int y,int z) {
		t=x;
		alice=y;
		bob=z;
		}
		@Override
		public int compareTo(BBOOK o) {
			return this.t-o.t;
		}
	}
	private static long lcm(long a2, long b2) {
	return (a2*b2)/gcd(a2,b2);
	}
	static class Edge implements Comparable<Edge>
	{
		int node;long cost ; long time;

		Edge(int a, long b,long c) { node = a;	cost = b; time=c; }

		public int compareTo(Edge e){ return Long.compare(time,e.time);	}
	}

        static void sieve(int N)	// O(N log log N)
	{
		isComposite = new int[N+1];
		isComposite[0] = isComposite[1] = 1;			// 0 indicates a prime number
		primes = new ArrayList<Integer>();

		for (int i = 2; i <= N; ++i) 					//can loop till i*i <= N if primes array is not needed O(N log log sqrt(N))
			if (isComposite[i] == 0) 					//can loop in 2 and odd integers for slightly better performance
			{
				primes.add(i);
				if(1l * i * i <= N)
					for (int j = i * i; j <= N; j += i)	// j = i * 2 will not affect performance too much, may alter in modified sieve
						isComposite[j] = 1;
			}
	}
    static TreeSet<Integer> factors;
    static TreeSet<Integer> primeFactors(int N)		// O(sqrt(N) / ln sqrt(N))
	{
		 factors = new TreeSet<Integer>();		//take abs(N) in case of -ve integers
		int idx = 0, p = primes.get(idx);

		while(1l*p * p <= N)
		{
			while(N % p == 0) { factors.add(p); N /= p; }
			p = primes.get(++idx);
		}

		if(N != 1)						// last prime factor may be > sqrt(N)
			factors.add(N);				// for integers whose largest prime factor has a power of 1
		return factors;
	}

	static class UnionFind {
		int[] p, rank, setSize;
		int numSets;
		int max[];

		public UnionFind(int N) {
			p = new int[numSets = N];
			rank = new int[N];
			setSize = new int[N];
			for (int i = 0; i < N; i++) {
				p[i] = i;
				setSize[i] = 1;
			}
		}

		public int findSet(int i) {
			return p[i] == i ? i : (p[i] = findSet(p[i]));
		}

		public boolean isSameSet(int i, int j) {
			return findSet(i) == findSet(j);
		}
		public int chunion(int i,int j, int x2) {
			if (isSameSet(i, j))
				return 0;
			numSets--;
			int x = findSet(i), y = findSet(j);
			int z=findSet(x2);
			p[x]=z;;
			p[y]=z;
		return x;
		}

		public void unionSet(int i, int j) {
			if (isSameSet(i, j))
				return;
			numSets--;
			int x = findSet(i), y = findSet(j);
			if (rank[x] > rank[y]) {
				p[y] = x;
				setSize[x] += setSize[y];

			} else {
				p[x] = y;
				setSize[y] += setSize[x];
				if (rank[x] == rank[y])
					rank[y]++;

			}
		}

		public int numDisjointSets() {
			return numSets;
		}

		public int sizeOfSet(int i) {
			return setSize[findSet(i)];
		}
	}

	static class Quad implements Comparable<Quad> {
		int u;
		int v;
		char state;
		int turns;

		public Quad(int i, int j, char c, int k) {
			u = i;
			v = j;
			state = c;
			turns = k;
		}

		public int compareTo(Quad e) {
			return (int) (turns - e.turns);
		}

	}

	static long manhatandistance(long x, long x2, long y, long y2) {
		return Math.abs(x - x2) + Math.abs(y - y2);
	}

	static long fib[];

	static long fib(int n) {
		if (n == 1 || n == 0) {
			return 1;
		}
		if (fib[n] != -1) {
			return fib[n];
		} else
			return fib[n] = ((fib(n - 2) % mod + fib(n - 1) % mod) % mod);
	}

	static class Point  implements Comparable<Point>{
		long x, y;

		Point(long counth, long counts) {
			x = counth;
			y = counts;
		}

		@Override
		public int compareTo(Point p )
		{
			return Long.compare(p.y*1l*x, p.x*1l*y);
		}
	}

	static TreeSet<Long> primeFactors(long N) // O(sqrt(N) / ln sqrt(N))
	{
		TreeSet<Long> factors = new TreeSet<Long>(); // take abs(N) in case of -ve integers
		int idx = 0, p = primes.get(idx);

		while (p * p <= N) {
			while (N % p == 0) {
				factors.add((long) p);
				N /= p;
			}
			if (primes.size() > idx + 1)
				p = primes.get(++idx);
			else
				break;
		}

		if (N != 1) // last prime factor may be > sqrt(N)
			factors.add(N); // for integers whose largest prime factor has a power of 1
		return factors;
	}

	static boolean visited[];

	/**
	 * static int bfs(int s) { Queue<Integer> q = new LinkedList<Integer>();
	 * q.add(s); int count=0; int maxcost=0; int dist[]=new int[n]; dist[s]=0;
	 * while(!q.isEmpty()) {
	 *
	 * int u = q.remove(); if(dist[u]==k) { break; } for(Pair v: adj[u]) {
	 * maxcost=Math.max(maxcost, v.cost);
	 *
	 *
	 *
	 * if(!visited[v.v]) {
	 *
	 * visited[v.v]=true; q.add(v.v); dist[v.v]=dist[u]+1; maxcost=Math.max(maxcost,
	 * v.cost); } }
	 *
	 * } return maxcost; }
	 **/

	static boolean[] vis2;

	static boolean f2 = false;

	static long[][] matMul(long[][] a2, long[][] b, int p, int q, int r) // C(p x r) = A(p x q) x (q x r) -- O(p x q x
																			// r)
	{
		long[][] C = new long[p][r];
		for (int i = 0; i < p; ++i) {
			for (int j = 0; j < r; ++j) {
				for (int k = 0; k < q; ++k) {
					C[i][j] = (C[i][j] + (a2[i][k] % mod * b[k][j] % mod)) % mod;
					C[i][j] %= mod;
				}

			}
		}
		return C;
	}
	public static int[] schuffle(int[] a2) {
		for (int i = 0; i < a2.length; i++) {
			int x =  (int) (Math.random() * a2.length);
			int temp = a2[x];
			a2[x] = a2[i];
			a2[i] = temp;
		}
		return a2;
	}

	static boolean vis[];
	static HashSet<Integer> set = new HashSet<Integer>();

	static long modPow(long ways, long count, long mod) // O(log e)
	{
		ways %= mod;
		long res = 1;
		while (count > 0) {
			if ((count & 1) == 1)
				res = (res * ways) % mod;
			ways = (ways * ways) % mod;
			count >>= 1;
		}
		return res % mod;
	}

	static long gcd(long l, long o) {
		if (o == 0) {
			return l;
		}
		return gcd(o, l % o);
	}

	static int[] isComposite;
	static int[] valid;

	static ArrayList<Integer> primes;
	static ArrayList<Integer> l1;

	static TreeSet<Integer> primus = new TreeSet<Integer>();

	static void sieveLinear(int N)
	{
		int[] lp = new int[N + 1];								//lp[i] = least prime divisor of i
		for(int i = 2; i <= N; ++i)
		{
			if(lp[i] == 0)
			{
				primus.add(i);
				lp[i] = i;
			}
			int curLP = lp[i];
			for(int p: primus)
				if(p > curLP || p * i > N)
					break;
				else
					lp[p * i] = i;
		}
	}

	public static long[] schuffle(long[] a2) {
		for (int i = 0; i < a2.length; i++) {
			int x =  (int) (Math.random() * a2.length);
			long temp = a2[x];
			a2[x] = a2[i];
			a2[i] = temp;
		}
		return a2;
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}

		public int[] nxtArr(int n) throws IOException {
			int[] ans = new int[n];
			for (int i = 0; i < n; i++)
				ans[i] = nextInt();
			return ans;
		}

	}
	public static int[] sortarray(int a[]) {
		schuffle(a);
		Arrays.sort(a);
		return a;
		}
		public static long[] sortarray(long a[]) {
			schuffle(a);
			Arrays.sort(a);
			return a;
		}
		public static int[] readarray(int n) throws IOException {
			int a[]=new int[n];
			for (int i = 0; i < a.length; i++) {
			a[i]=sc.nextInt();
			}
			return a;
		}
		public static long[] readlarray(int n) throws IOException {
			long a[]=new long[n];
			for (int i = 0; i < a.length; i++) {
			a[i]=sc.nextLong();
			}
			return a;
		}
}


import java.io.*;
import java.util.*;

public class Main {
    private static final boolean N_CASE = false;
    private static final int N = 2000005;
    private static final int M = 1000_000_007;

    private void solve() {
        int[] dp = new int[N];
        int[] r = new int[N];
        dp[3] = dp[4] = 4;
        r[3] = 1; r[4] = 0;
        for (int i = 5; i < N; ++i) {
            dp[i] = (dp[i - 1] + (2 * dp[i - 2]) % M) % M;
            if (r[i - 1] == 0 && r[i - 2] == 0) {
                dp[i] = (dp[i] + 4) % M;
                r[i] = 1;
            }
        }

        int t = sc.nextInt();
        for (int i = 0; i < t; i++) {
            int n = sc.nextInt();
            out.println(dp[n]);
        }
    }

    private void run() {
        int T = N_CASE ? sc.nextInt() : 1;
        for (int t = 0; t < T; ++t) {
            solve();
        }
    }

    private static MyWriter out;
    private static MyScanner sc;

    private static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        private MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

        int[][] nextIntArray(int n, int m) {
            int[][] a = new int[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    a[i][j] = sc.nextInt();
                }
            }
            return a;
        }

        long[][] nextLongArray(int n, int m) {
            long[][] a = new long[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    a[i][j] = nextLong();
                }
            }
            return a;
        }

        List<Integer> nextList(int n) {
            List<Integer> list = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                list.add(nextInt());
            }
            return list;
        }

        List<Long> nextLongList(int n) {
            List<Long> list = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                list.add(nextLong());
            }
            return list;
        }

        char[] nextCharArray(int n) {
            return sc.next().toCharArray();
        }

        char[][] nextCharArray(int n, int m) {
            char[][] c = new char[n][m];
            for (int i = 0; i < n; i++) {
                String s = sc.next();
                for (int j = 0; j < m; j++) {
                    c[i][j] = s.charAt(j);
                }
            }
            return c;
        }
    }

    private static class MyWriter extends PrintWriter {
        private MyWriter(OutputStream outputStream) {
            super(outputStream);
        }

        void printArray(int[] a) {
            for (int i = 0; i < a.length; ++i) {
                print(a[i]);
                print(i == a.length - 1 ? '\n' : ' ');
            }
        }

        void printlnArray(int[] a) {
            for (int v : a) {
                println(v);
            }
        }

        void printList(List<Integer> list) {
            for (int i = 0; i < list.size(); ++i) {
                print(list.get(i));
                print(i == list.size() - 1 ? '\n' : ' ');
            }
        }

        void printlnList(List<Integer> list) {
            list.forEach(this::println);
        }
    }

    private <T> List<List<T>> createGraph(int n) {
        List<List<T>> g = new ArrayList<>();
        for (int i = 0; i < n; ++i) {
            g.add(new ArrayList<>());
        }
        return g;
    }

    public static void main(String[] args) {
        out = new MyWriter(new BufferedOutputStream(System.out));
        sc = new MyScanner();
        new Main().run();
        out.close();
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Nikita Mikhailov
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        DSozdateLi solver = new DSozdateLi();
        solver.solve(1, in, out);
        out.close();
    }

    static class DSozdateLi {
        int testNumber;
        InputReader in;
        OutputWriter out;
        int MAXN = (int) (2 * 1e6 + 100);
        long MOD = (long) (1e9 + 7L);
        long[][] cache = new long[2][MAXN + 1];

        long calc(int n, int k) {
            if (n <= 2) {
                return 0;
            }
            if (cache[k][n] == -1) {
                long res = 0;

                if (k == 1) {

                    long res1 = (4 + calc(n - 1, 0) + 2L * calc(n - 2, 0)) % MOD;
                    long res2 = (calc(n - 1, 1) + 2L * calc(n - 2, 1)) % MOD;

                    res = Math.max(res1, res2);
                } else {
                    res = (calc(n - 1, 1) + 2L * calc(n - 2, 1)) % MOD;
                }
                cache[k][n] = res;
            }

            return cache[k][n];
        }

        public void solve() {
            for (int i = 0; i < 2; i++) {
                Arrays.fill(cache[i], -1L);
            }

            for (int i = 2; i < MAXN; i++) {
                calc(i, 1);
                calc(i, 0);
            }

            int t = in.readInt();
            for (int i = 0; i < t; i++) {
                int n = in.readInt();
                out.println(calc(n, 1));
//            out.println(Math.max(calc(n, 1), calc(n, 0)));
//            out.println(calc(n, 0) + " " + calc(n,1));
            }

        }

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            this.testNumber = testNumber;
            this.in = in;
            this.out = out;

            solve();
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void println(long i) {
            writer.println(i);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DTediousLee solver = new DTediousLee();
        solver.solve(1, in, out);
        out.close();
    }

    static class DTediousLee {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int t = in.nextInt();
            int n = 2000001;
            long mod = 1000000007;
            long dp[][] = new long[n][3];
            dp[0][0] = 1;
            dp[1][0] = 1;
            dp[1][1] = 1;
            for (int i = 2; i < n; i++) {
                dp[i][0] = (dp[i - 1][0] + 2 * dp[i - 1][1]) % mod;
                dp[i][1] = dp[i - 1][0] % mod;
                dp[i][2] = (dp[i - 1][1] * 4) % mod;
            }
            for (int i = 3; i < n; i++) {
                dp[i][2] += dp[i - 3][2];
                dp[i][2] %= mod;
            }
            while (t-- > 0) {
                int x = in.nextInt();
                out.println(dp[x - 1][2]);
            }

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.util.*;

public class D {
    static int dp[] = new int[2000005];
    static int mod = 1000000007;

    static void solve() {
        int n = 2000005;
        dp[0] = 0;
        dp[1] = 0;
        dp[2] = 0;
        dp[3] = 1;

        for (int i = 4; i < n; i++) {
            if (i % 3 == 0)
                dp[i] = (int) ((long) dp[i - 1] + ((long) 2 * dp[i - 2]) % mod + 1) % mod;
            else
                dp[i] = (int) ((long) dp[i - 1] + ((long) 2 * dp[i - 2]) % mod) % mod;
        }
    }

    public static void main(String[] args) {
        solve();
        Scanner sc = new Scanner(System.in);
        int testCases = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        for (int t = 0; t < testCases; t++) {
            int n = sc.nextInt();
            long ans = ((long) dp[n] * 4) % mod;
            sb.append(ans).append("\n");
        }
        System.out.print(sb);
    }
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.*;

public class psykibaek {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int totCase = scanner.nextInt();

        long[] dic = new long[2000001];
        dic[1] = 0;
        dic[2] = 0;
        int this_cc = 2;
        while (totCase-- > 0) {
            long n = scanner.nextLong();
            if (n <= 2){
                System.out.println(0);
                continue;
            }

            if (n <= this_cc) {
                System.out.println(dic[(int) n]);
                continue;
            }
            for (int i = this_cc+1; i <= n; i++) {
                if (i % 3 == 0) {
                    dic[i] = (dic[i - 2] * 2 + dic[i - 1] + 4) % (1000000007);
                } else {
                    dic[i] = (dic[i - 2] * 2 + dic[i - 1]) % (1000000007);
                }
                this_cc = i;
            }
            System.out.println( dic[(int) n] );
        }
    }

    public static boolean isDebug = false;
}


import java.util.*;
//import java.lang.*;
import java.io.*;
import java.math.*;

public class tediousLee
{
	static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

	public static void main(String args[]) throws IOException
	{
		FastReader fr=new FastReader();
		int t= fr.nextInt();

		for(int i=0; i<t; i++)
		{
			long n=fr.nextLong();
			int m=1000000007;
			long dp[]=new long[(int)(n+1)];
			long ans=Integer.MIN_VALUE;
			dp[1]=0;
			dp[2]=0;
			for(long j=3; j<=n; j++)
			{
				dp[(int)j]=dp[(int)(j-1)] + 2*dp[(int)(j-2)] + ((int)(j%3)==0?1:0);
				dp[(int)j]=dp[(int)j]%m;
			}
			ans=dp[(int)(n)]*4;
			ans=ans%m;

			StringBuffer sb=new StringBuffer();
			sb.append(ans);
			System.out.println(sb);
		}
	}
}


import java.util.*;
//import java.lang.*;
import java.io.*;
import java.math.*;

public class tediousLee
{
	static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

	public static void main(String args[]) throws IOException
	{
		FastReader fr=new FastReader();
		int t= fr.nextInt();

		for(int i=0; i<t; i++)
		{
			long n=fr.nextLong();
			int m=1000000007;
			long dp[]=new long[(int)(n+2)];
			long ans=Integer.MIN_VALUE;
			dp[1]=0;
			dp[2]=0;
			for(long j=3; j<=n; j++)
			{
				dp[(int)j]=dp[(int)(j-1)] + 2*dp[(int)(j-2)] + ((int)(j%3)==0?1:0);
				dp[(int)j]=dp[(int)j]%m;
			}
			ans=dp[(int)(n)]*4;
			ans=ans%m;

			StringBuffer sb=new StringBuffer();
			sb.append(ans);
			System.out.println(sb);
		}
	}
}


import java.util.*;
//import java.lang.*;
import java.io.*;
import java.math.*;

public class tediousLee
{
	public static void main(String args[]) throws IOException
	{
		Scanner sc=new Scanner(System.in);
		int t= sc.nextInt();

		for(int i=0; i<t; i++)
		{
			int n=sc.nextInt();
			int m=1000000007;
			long dp[]=new long[(int)(n+2)];
			long ans=Integer.MIN_VALUE;
			dp[1]=0;
			dp[2]=0;
			for(int j=3; j<=n; j++)
			{
				dp[j]=dp[j-1] + 2*dp[j-2] + (j%3==0?1:0);
				dp[j]=dp[j]%m;
			}
			ans=dp[n]*4;
			ans=ans%m;

			StringBuffer sb=new StringBuffer();
			sb.append(ans);
			System.out.println(sb);
		}
	}
}


import java.util.*;
//import java.lang.*;
import java.io.*;
import java.math.*;

public class tediousLee
{
	static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

	public static void main(String args[]) throws IOException
	{
		FastReader fr=new FastReader();
		int t= fr.nextInt();

		for(int i=0; i<t; i++)
		{
			int n=fr.nextInt();
			int m=1000000007;
			long dp[]=new long[(int)(n+2)];
			long ans=Integer.MIN_VALUE;
			dp[1]=0;
			dp[2]=0;
			for(int j=3; j<=n; j++)
			{
				dp[j]=dp[j-1] + 2*dp[j-2] + (j%3==0?1:0);
				dp[j]=dp[j]%m;
			}
			ans=dp[n]*4;
			ans=ans%m;

			StringBuffer sb=new StringBuffer();
			sb.append(ans);
			System.out.println(sb);
		}
	}
}


import java.util.*;
//import java.lang.*;
import java.io.*;
import java.math.*;

public class tediousLee
{
	static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

	public static void main(String args[]) throws IOException
	{
		FastReader fr=new FastReader();
		int t= fr.nextInt();

		for(int i=0; i<t; i++)
		{
			long n=fr.nextLong();
			long dp[]=new long[(int)(n+3)];
			long ans=Integer.MIN_VALUE;
			dp[0]=0L;
			dp[1]=0L;
			dp[2]=0L;
			dp[3]=1L;
			for(long j=4L; j<=n; j++)
			{
				dp[(int)j]=dp[(int)(j-1)] + 2*dp[(int)(j-2)] + ((int)(j%3)==0?1:0);
			}
			ans=(dp[(int)(n)]*4)%(long)(Math.pow(10,9)+7);
			StringBuffer sb=new StringBuffer();
			sb.append(ans);
			System.out.println(sb);
		}
	}
}


import java.util.*;
//import java.lang.*;
import java.io.*;
import java.math.*;

public class tediousLee
{
	static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

	public static void main(String args[]) throws IOException
	{
		FastReader fr=new FastReader();
		int t= fr.nextInt();
		int m=1000000007;
		long dp[]=new long[2000001];
		long ans=Integer.MIN_VALUE;
		dp[1]=0;
		dp[2]=0;
		for(int j=3; j<=2000000; j++)
		{
			dp[j]=dp[j-1] + 2*dp[j-2] + (j%3==0?1:0);
			dp[j]=dp[j]%m;
		}

		for(int i=0; i<t; i++)
		{
			int n=fr.nextInt();
			StringBuffer sb=new StringBuffer();
			sb.append((dp[n]*4)%m);
			System.out.println(sb);
		}
	}
}


	import java.io.*;
	import java.util.*;
	import java.math.*;

	 public class Main	{
	   static class Pair implements Comparable<Pair>{
	   long a;
	   int b;
	   public Pair(long x,int y){a=x;b=y;}
	   public Pair(){}
	   public int compareTo(Pair p){

		   return Long.compare(a, p.a);

	   }
//	@Override
//	public int hashCode() {
//		final int prime = 31;
//		int result = 1;
//		result = prime * result + a;
//		result = prime * result + b;
//	//	out.println("hashcode = "+result);
//		return result;
//	}
	@Override
	public boolean equals(Object obj) {
		Pair cur = (Pair)obj;
		if((a==cur.a && b==cur.b) || (a==cur.b && b==cur.a))return true;
		return false;
	}
	 }

	   static class cell implements Comparable<cell>{
		   int a,b;
		   long dis;
		   public cell(int x,int y,long z) {a=x;b=y;dis=z;}
		   public int compareTo(cell c) {
			   return Long.compare(dis,c.dis);
		   }
	   }
	static class TrieNode{
		TrieNode left;
		TrieNode right;
		int op;
		int data;
		public TrieNode() {}
	}
	  public static int gcd(int a,int b)
	  {
	    if(a<b)

	      return gcd(b,a);
	    if(b==0)
	      return a;
	    return gcd(b,a%b);

	  }
	  static int lcm(int a,int b) {
		  return  a*b / gcd(a,b);
	  }
	  //static long ans = 0;
	  static long mod = (long)(1e9+7); //998244353;//

	    public static void main(String[] args) throws Exception {
	       new Thread(null, null, "Anshum Gupta", 99999999) {
	            public void run() {
	                try {
	                    solve();
	                } catch(Exception e) {
	                    e.printStackTrace();
	                    System.exit(1);
	                }
	            }
	        }.start();
	    }

	static long pow(long x,long y){
	    if(y == 0)return 1;
	    if(y==1)return x;
	    long a = pow(x,y/2);
	    a = (a*a)%mod;
	    if(y%2==0){
	        return a;
	    }
	    return (a*x)%mod;
	}

	static long mxx;
	static int mxN = (int)(2e6+5);
	static long[]fact,inv_fact;
	static long my_inv(long a) {
		return pow(a,mod-2);
	}
	static long bin(int a,int b) {
		if(a < b || a<0 || b<0)return 0;
	    return ((fact[a]*inv_fact[a-b])%mod * inv_fact[b])%mod;
	}
	static ArrayList<ArrayList<Integer>>adj;
	static boolean[]vis;
	static void make_facts() {
	  fact=new long[mxN];
	  inv_fact = new long[mxN];
	  fact[0]=inv_fact[0]=1L;
	  for(int i=1;i<mxN;i++) {
		   fact[i] = (i*fact[i-1])%mod;
		   inv_fact[i] = my_inv(fact[i]);
	  }
	}
	//static int[]bfs(int a){
	//	Queue<Integer> q = new  LinkedList<Integer>();
	//
	//	vis = new boolean[n+1];
	//	int[]dis = new int[n+1];
	//	q.add(a);
	//	dis[a] = 0;
	//	vis[a] = true;
	//	while(!q.isEmpty()) {
	//		int cur = q.poll();
	//	//	vis[cur] = true;
	//	//	if(cur == b)break;
	//		for(int x : adj.get(cur)) {
	//			if(vis[x])continue;
	//			q.add(x);
	//			dis[x] = dis[cur]+1;
	//			vis[x] = true;
	//		}
	//	}
	//	return dis;
	//}
	 public static void solve() throws Exception {
	   // solve the problem here
	   MyScanner s = new MyScanner();
	        out = new PrintWriter(new BufferedOutputStream(System.out), true);
	        int tc = s.nextInt();
	        mxx = (long)(1e18+5);
	//        make_facts();
	        long[]dp = new long[mxN];
	        dp[3] = dp[4] = 4;
        	for(int i=5;i<mxN;i++) {
        		dp[i] = ((dp[i-2]*2)%mod + dp[i-1])%mod;
        		if(i % 3 == 0) {
        			dp[i] = (dp[i]+4)%mod;
        		}
        	}
	        while(tc-->0){
	        	int n = s.nextInt();
	        	out.println(dp[n]);
	        }

	        out.flush();
	}

	    //-----------PrintWriter for faster output---------------------------------
	    public static PrintWriter out;

	    //-----------MyScanner class for faster input----------
	    public static class MyScanner {
	        BufferedReader br;
	        StringTokenizer st;

	        public MyScanner() {
	            br = new BufferedReader(new InputStreamReader(System.in));
	        }

	        String next() {
	            while (st == null || !st.hasMoreElements()) {
	                try {
	                    st = new StringTokenizer(br.readLine());
	                } catch (IOException e) {
	                    e.printStackTrace();
	                }
	            }
	            return st.nextToken();
	        }

	        int nextInt() { return Integer.parseInt(next()); }
	        long nextLong() { return Long.parseLong(next()); }
	        double nextDouble() { return Double.parseDouble(next()); }

	        String nextLine(){
	            String str = "";
	            try {
	                str = br.readLine();
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	            return str;
	        }
	    }
	    //--------------------------------------------------------
	}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author sofiane
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int t = in.nextInt();
            int m = (int) 2e6 + 1;
            int mod = (int) 1e9 + 7;
            int[] dp = new int[m];
            for (int i = 3; i < m; i++)
                dp[i] = ((2 * dp[i - 2]) % mod + dp[i - 1] % mod + (i % 3 == 0 ? 1 : 0) * 4) % mod;
            while (t-- > 0) {
                int n = in.nextInt();
                out.println(dp[n]);
            }
        }

    }
}


import java.io.*;
import java.util.*;
import java.math.*;

public class CF1369D {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int T = in.nextInt();
        int P = 1000000007;

        long a[] = new long [2000001];
        a[1] = 0;
        a[2] = 0;
        for(int i = 3; i < 2000001; ++i) {
            a[i] = (a[i - 1] + a[i - 2] * 2 + (i % 3 == 0 ? 4 : 0)) % P;
        }

        while(T --> 0) {
            int n = in.nextInt();
            System.out.println(a[n]);
        }
    }
}


import java.io.*;
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);
	static final int MAXN = (int) 2e6 + 5, MOD = (int) 1e9 + 7;

	static int fix(long x) {
		return (int) (x % MOD + MOD) % MOD;
	}

	public static void main(String[] args) throws Exception {
		int dp[] = new int[MAXN];
		for(int i = 3; i < MAXN; i++) {
			long cur = (2L * dp[i - 2] + dp[i - 1]);
			dp[i] = fix(cur + (i % 3 == 0 ? 4 : 0));
		}

		int t = sc.nextInt();
		while(t-- > 0) out.println(dp[sc.nextInt()]);
		out.close();
	}

}

class Scanner {
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream system) {
		br = new BufferedReader(new InputStreamReader(system));
	}

	public Scanner(String file) throws Exception {
		br = new BufferedReader(new FileReader(file));
	}

	public String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public String nextLine() throws IOException {
		return br.readLine();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	public Long nextLong() throws IOException {
		return Long.parseLong(next());
	}
}


import java.io.*;
import java.text.*;
import java.util.*;
import java.math.*;
public class template {
    public static void main(String[] args) throws Exception {
        new template().run();
    }
    public void run() throws Exception {
        FastScanner f = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        ///
        long[] dp = new long[2000001];
        dp[3] = 4;
        for(int i = 4; i < dp.length; i++)
            dp[i] = ((i%3 == 0 ? 4 : 0) + 2*dp[i-2]+dp[i-1]) % 1000000007;
        int asdf = f.nextInt();
        while(asdf-->0) out.println(dp[f.nextInt()]);
///
		out.flush();
	}
///
	static class FastScanner {
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		public FastScanner() {
			reader = new BufferedReader(new InputStreamReader(System.in), 32768);
			tokenizer = null;
		}
		public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch(IOException e) {
				throw new RuntimeException(e);
			}
		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 * Accomplished using the EduTools plugin by JetBrains https://plugins.jetbrains.com/plugin/10081-edutools
 */

public class Main {
   static int mod = (int)1e9 + 7;
   static int max = (int)2e6 + 7;
   public static void main(String[] args) {
      // Write your solution here
      FastReader in = new FastReader();
      long[] dp = new long[max];
      dp[0] = 0; dp[1] = 0; dp[2] = 0; dp[3] = 4; dp[4] = 4;
      for(int i = 5; i < max; i++){
         dp[i] = 2 * dp[i - 2] + dp[i - 1];
         if(i % 3 == 0){
            dp[i] += 4;
         }
         dp[i] = dp[i] % mod;
      }
      int t = in.nextInt();
      while (t-- > 0){
         int n = in.nextInt();
         System.out.println(dp[n]);
      }
   }
   static class FastReader
   {
      BufferedReader br;
      StringTokenizer st;

      public FastReader()
      {
         br = new BufferedReader(new
                 InputStreamReader(System.in));
      }

      String next()
      {
         while (st == null || !st.hasMoreElements())
         {
            try
            {
               st = new StringTokenizer(br.readLine());
            }
            catch (IOException e)
            {
               e.printStackTrace();
            }
         }
         return st.nextToken();
      }

      int nextInt()
      {
         return Integer.parseInt(next());
      }

      long nextLong()
      {
         return Long.parseLong(next());
      }

      double nextDouble()
      {
         return Double.parseDouble(next());
      }

      String nextLine()
      {
         String str = "";
         try
         {
            str = br.readLine();
         }
         catch (IOException e)
         {
            e.printStackTrace();
         }
         return str;
      }
   }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 * Accomplished using the EduTools plugin by JetBrains https://plugins.jetbrains.com/plugin/10081-edutools
 */

public class Main {
   static int mod = (int)1e9 + 7;
   static int max = (int)2e6 + 7;
   public static void main(String[] args) {
      // Write your solution here
      FastReader in = new FastReader();
      int t = in.nextInt();
      while (t-- > 0){
         int n = in.nextInt();
         long[] dp = new long[max];
         dp[0] = 0; dp[1] = 0; dp[2] = 0; dp[3] = 4; dp[4] = 4;
         for(int i = 5; i < max; i++){
            dp[i] = 2 * dp[i - 2] + dp[i - 1];
            if(i % 3 == 0){
               dp[i] += 4;
            }
            dp[i] = dp[i] % mod;
         }
         System.out.println(dp[n]);
      }
   }
   static class FastReader
   {
      BufferedReader br;
      StringTokenizer st;

      public FastReader()
      {
         br = new BufferedReader(new
                 InputStreamReader(System.in));
      }

      String next()
      {
         while (st == null || !st.hasMoreElements())
         {
            try
            {
               st = new StringTokenizer(br.readLine());
            }
            catch (IOException e)
            {
               e.printStackTrace();
            }
         }
         return st.nextToken();
      }

      int nextInt()
      {
         return Integer.parseInt(next());
      }

      long nextLong()
      {
         return Long.parseLong(next());
      }

      double nextDouble()
      {
         return Double.parseDouble(next());
      }

      String nextLine()
      {
         String str = "";
         try
         {
            str = br.readLine();
         }
         catch (IOException e)
         {
            e.printStackTrace();
         }
         return str;
      }
   }
}


import java.io.*;
import java.lang.reflect.Array;
import java.math.*;
import java.util.*;

public class Main {
	static final int INF = (int) (1e9 + 10);
	static final long MOD = (int) (1e9 + 7);
	static final int N = (int) (4e5 + 5);
	// static ArrayList<Integer>[] graph;
	// static boolean visited[];
	// static long size[];

	public static void main(String[] args) throws NumberFormatException, IOException {
		FastReader sc = new FastReader();
		PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		// Scanner scn = new Scanner(System.in);
		//
		long arr[] = new long[2000005];
		long on = 1;
		long tw = 0;
		long cl = 0;
		long prvcl = 0;
		long prvt = 0;
		arr[3] = 1;
		for (int i = 4; i <= 2000000; i++) {
			arr[i] = ((arr[i - 2] * 2) + arr[i - 1]) % MOD;
			if (i % 3 == 0)
				arr[i]++;
		}
		int t = sc.nextInt();
		while (t-- > 0) {
			int n = sc.nextInt();

			pr.println((arr[n] * 4) % MOD);
		}
		//
		// Coded to Perfection by Rohan Mukhija
		pr.flush();
		pr.close();
	}

	/*
	 * Template From Here
	 */
	private static boolean possible(long[] arr, long mid, long k, long t) {
		long c = 1;
		long tot = 0;
		for (int i = 0; i < arr.length; i++) {
			tot += (arr[i]);
			if (tot > mid) {
				tot = arr[i];
				c++;
			}
		}
		// System.out.println(mid+" "+c);
		if (c <= k)
			return true;
		return false;
	}

	public static class Pair implements Comparable<Pair> {
		int u;
		int v;

		Pair(int u, int v) {
			this.u = u;
			this.v = v;

		}

		public int compareTo(Pair compareEdge) {
			return Long.compare(this.v, compareEdge.v);
		}
	};

	static void sort(long[] a) {
		ArrayList<Long> l = new ArrayList<>();
		for (long i : a)
			l.add(i);
		Collections.sort(l);
		for (int i = 0; i < a.length; i++)
			a[i] = l.get(i);
	}

	static void sort(int[] a) {
		ArrayList<Integer> l = new ArrayList<>();
		for (int i : a)
			l.add(i);
		Collections.sort(l);
		for (int i = 0; i < a.length; i++)
			a[i] = l.get(i);
	}

	public static int lowerBound(ArrayList<Integer> array, int length, long value) {
		int low = 0;
		int high = length;
		while (low < high) {
			final int mid = (low + high) / 2;
			if (value <= array.get(mid)) {
				high = mid;
			} else {
				low = mid + 1;
			}
		}
		return low;
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
	}

	static long gcd(long a, long b) {
		if (a == 0)
			return b;
		return gcd(b % a, a);
	}

	static long lcm(long a, long b) {
		return (a * b) / gcd(a, b);
	}

	public static void sortbyColumn(int[][] att, int col) {
		// Using built-in sort function Arrays.sort
		Arrays.sort(att, new Comparator<int[]>() {

			@Override
			// Compare values according to columns
			public int compare(final int[] entry1, final int[] entry2) {

				// To sort in descending order revert
				// the '>' Operator
				// if (entry1[col] > entry2[col])
				// return 1;
				// else //(entry1[col] >= entry2[col])
				// return -1;
				return new Integer(entry1[col]).compareTo(entry2[col]);
				// return entry1[col].
			}
		}); // End of function call sort().
	}

	public static void sortbyColumn(double[][] att, int col) {
		// Using built-in sort function Arrays.sort
		Arrays.sort(att, new Comparator<double[]>() {

			@Override
			// Compare values according to columns
			public int compare(final double[] entry1, final double[] entry2) {

				// To sort in descending order revert
				// the '>' Operator
				// if (entry1[col] > entry2[col])
				// return 1;
				// else //(entry1[col] >= entry2[col])
				// return -1;
				return new Double(entry1[col]).compareTo(entry2[col]);
				// return entry1[col].
			}
		}); // End of function call sort().
	}

	static class pair {
		int V, I;

		pair(int v, int i) {
			V = v;
			I = i;
		}
	}

	public static int[] swap(int data[], int left, int right) {
		int temp = data[left];
		data[left] = data[right];
		data[right] = temp;
		return data;
	}

	public static int[] reverse(int data[], int left, int right) {
		while (left < right) {
			int temp = data[left];
			data[left++] = data[right];
			data[right--] = temp;
		}
		return data;
	}

	public static boolean findNextPermutation(int data[]) {
		if (data.length <= 1)
			return false;

		int last = data.length - 2;
		while (last >= 0) {
			if (data[last] < data[last + 1]) {
				break;
			}
			last--;
		}
		if (last < 0)
			return false;

		int nextGreater = data.length - 1;
		for (int i = data.length - 1; i > last; i--) {
			if (data[i] > data[last]) {
				nextGreater = i;
				break;
			}
		}
		data = swap(data, nextGreater, last);
		data = reverse(data, last + 1, data.length - 1);
		return true;
	}

	static long ncr(long a, long b) {
		if (b > a - b)
			return ncr(a, a - b);
		long ansMul = 1;
		long ansDiv = 1;
		for (int i = 0; i < b; i++) {
			ansMul *= (a - i);
			ansDiv *= (i + 1);
			ansMul %= MOD;
			ansDiv %= MOD;
		}

		long ans = ansMul * power(ansDiv, MOD - 2, MOD) % MOD;

		return ans;
	}

	static long __gcd(long n1, long n2) {
		long gcd = 1;

		for (int i = 1; i <= n1 && i <= n2; ++i) {
			// Checks if i is factor of both integers
			if (n1 % i == 0 && n2 % i == 0) {
				gcd = i;
			}
		}
		return gcd;
	}

	static long power(long prev, long n2, long mod2) {
		long res = 1;

		prev = prev % mod2;

		if (prev == 0)
			return 0;
		while (n2 > 0) {

			if ((n2 & 1) == 1)
				res = (res * prev) % mod2;

			n2 = n2 >> 1;
			prev = (prev * prev) % mod2;
		}
		return res;
	}

	static long modInverse(long fac2, int p) {
		return power(fac2, p - 2, p);
	}

	static boolean isPrime(int n) {
		// Corner cases
		if (n <= 1)
			return false;
		if (n <= 3)
			return true;

		// This is checked so that we can skip
		// middle five numbers in below loop
		if (n % 2 == 0 || n % 3 == 0)
			return false;

		for (int i = 5; i * i <= n; i = i + 6)
			if (n % i == 0 || n % (i + 2) == 0)
				return false;

		return true;
	}

	public static BigInteger lcmm(String a, String b) {
		BigInteger s = new BigInteger(a);
		BigInteger s1 = new BigInteger(b);
		BigInteger mul = s.multiply(s1);
		BigInteger gcd = s.gcd(s1);
		BigInteger lcm = mul.divide(gcd);
		return lcm;
	}
	/*
	 * static boolean prime[] = new boolean[10000007]; static int spf[] = new
	 * int[10000007];
	 *
	 * public static void sieveOfEratosthenes(int n) { for (int i = 2; i < n;
	 * i++) prime[i] = true; for (int p = 2; p * p <= n; p++) {
	 *
	 * if (prime[p] == true) {
	 *
	 * for (int i = p * p; i <= n; i += p) { prime[i] = false; spf[i] = p; } } }
	 * }
	 */
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Task4 {

    public static void main(String[] args) throws IOException {
        new Task4().solve();
    }

    private void solve() throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        int t = Integer.parseInt(f.readLine());
        int upTo = 2000001;
        int mod = 1000000007;
        long[] dp2 = new long[upTo];
        dp2[3] = 4;
        boolean[] isTaken = new boolean[upTo];
        isTaken[3] = true;
        for (int i = 4; i < upTo; i++) {
            if (isTaken[i - 1] || isTaken[i - 2]) {
                dp2[i] = dp2[i - 1] + dp2[i - 2] * 2;
            } else {
                dp2[i] = 4 + dp2[i - 2] * 2 + dp2[i - 1];
                isTaken[i] = true;
            }
            dp2[i] %= mod;
        }

        for (int t1 = 0; t1 < t; t1++) {
            int n = Integer.parseInt(f.readLine());
            out.println(dp2[n]);
        }

        /*
        for (int i = 2; i < 60; i++) {
            System.out.println((dp[0][2][i] > dp[1][2][i]) + " " + i);
        } */
        out.close();
    }
}


import java.util.*;
import java.io.*;
public class GFG {
      public static void main (String[] args) {
		Scanner sc=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		int t=sc.nextInt();
		int m=1000000007;
		int arr[]=new int[2000001];
		arr[1]=0;
		arr[2]=0;
		for(int i=3;i<2000001;i++)
		arr[i]=(arr[i-1]%m+(2*arr[i-2])%m+(i%3==0?4:0))%m;
		while(t-->0){
		   int n=sc.nextInt();
		   System.out.println(arr[n]);
		}
    }
}


import java.util.*;

public class Solution {
    static long[] dp=new long[2000001];
    static  int mod=1000000007;

    public static void main(String[] args) {

        Scanner input=new Scanner(System.in);
        int t=input.nextInt();
        filldp();
        while (t-->0){
            int n=input.nextInt();
            System.out.println((dp[n]*4)%mod);
        }

    }

    private static void filldp() {
        dp[1]=0;
        dp[2]=0;
        for (int i = 3; i <=2000000 ; i++) {
            if (i%3==0){
                dp[i]=(dp[i-1]+2*dp[i-2]+1)%mod;
            }else {
                dp[i]=(dp[i-1]+2*dp[i-2])%mod;
            }

        }
    }

}


import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt();
        long[][] dp = new long[2][2000000+1];
        dp[1][3] = 1;
        int mod = 1000000007;
        int i=4;
        while (t-- > 0) {
            int n = scanner.nextInt();
            if (n < 3)
                System.out.println(0);
            else {
                for (; i <= n; ++i) {
                    dp[0][i] = ((2 * (Math.max(dp[0][i - 2], dp[1][i - 2])) % mod) % mod + Math.max(dp[0][i - 1], dp[1][i - 1]) % mod) % mod;
                    dp[1][i] = (1 + ((2 * dp[0][i - 2]) % mod + dp[0][i - 1] % mod)) % mod;
                }
                System.out.println((4 * Math.max(dp[0][n], dp[1][n])) % mod);
            }
        }
    }
}


import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt();
        while (t-- > 0) {
            int n = scanner.nextInt();
            long[][] dp = new long[2][n + 1];
            int mod = 1000000007;
            if (n < 3)
                System.out.println(0);
            else {
                dp[0][1] = 0;
                dp[1][1] = 0;
                dp[0][2] = 0;
                dp[1][2] = 0;
                dp[0][3] = 0;
                dp[1][3] = 1;
                for (int i = 4; i <= n; ++i) {
                    dp[0][i] = ((2 * (Math.max(dp[0][i - 2], dp[1][i - 2])) % mod) % mod + Math.max(dp[0][i - 1], dp[1][i - 1]) % mod) % mod;
                    dp[1][i] = (1 + ((2 * dp[0][i - 2]) % mod + dp[0][i - 1] % mod)) % mod;
                }
                System.out.println((4 * Math.max(dp[0][n], dp[1][n])) % mod);
            }
        }
    }
}


import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt();
        long[][] dp = new long[2][2000000+1];
        dp[0][1] = 0;
        dp[1][1] = 0;
        dp[0][2] = 0;
        dp[1][2] = 0;
        dp[0][3] = 0;
        dp[1][3] = 1;
        int i=4;
        int mod = 1000000007;
        while (t-- > 0) {
            int n = scanner.nextInt();
            if (n < 3)
                System.out.println(0);
            else {
                for (; i <= n; ++i) {
                    dp[0][i] = ((2 * (Math.max(dp[0][i - 2], dp[1][i - 2])) % mod) % mod + Math.max(dp[0][i - 1], dp[1][i - 1]) % mod) % mod;
                    dp[1][i] = (1 + ((2 * dp[0][i - 2]) % mod + dp[0][i - 1] % mod)) % mod;
                }
                System.out.println((4 * Math.max(dp[0][n], dp[1][n])) % mod);
            }
        }
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DTediousLee solver = new DTediousLee();
        solver.solve(1, in, out);
        out.close();
    }

    static class DTediousLee {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            int t = s.nextInt();
            int N = (int) 2e6 + 10, mod = 1000000007;
            long[] x = new long[N + 1], y = new long[N + 1];
            y[2] = y[1] = 1;
            x[2] = 1;

            for (int i = 3; i <= N; i++) {
                x[i] = (x[i - 3] + y[i - 1]) % mod;
                y[i] = (y[i - 1] + 2 * y[i - 2]) % mod;
            }
            while (t-- > 0) {
                int n = s.nextInt();
                out.println(4 * x[n - 1] % mod);

            }
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


import java.util.*;
import java.lang.*;
import java.io.*;

public class second{
	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok;
    public static int maximum=1000000007;

    public static boolean valid(long x,long y,int n,int m)
    {
    	return x>=0 && y>=0 && x<n && y<m;
    }

    public void go() throws IOException
    {
    	String test =  in.readLine();
    	if(test==null || test.trim().length()==0 )
    		return ;

    	 tok = new StringTokenizer(test);

       int tt = Integer.parseInt(tok.nextToken());

    	long max=2000001;
    	long dp[]=new long[(int)max];
    	dp[3]=1;
    	dp[4]=1;
    	for(int i=5;i<max;i++)
    	{
    		dp[i]=(dp[i-1]+2*dp[i-2]+(i%3==0?1:0))%maximum;
    	}

        for (int q = 0; q < tt; q++)
        {
          ntok();
          int n=ipar();
          System.out.println((dp[n]*4)%maximum);

        }

        out.flush();
        in.close();

    }

    public void ntok() throws IOException
    {  String test =  in.readLine();
	if(test==null || test.trim().length()==0 )
		return ;
        tok = new StringTokenizer(test);
    }

    public int ipar()
    {   String test=tok.nextToken();
      if(test==null || test.trim().length()==0)
    	  return 0;

        return Integer.parseInt(test);
    }

    public int[] iapar(int n)
    {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++)
        {
            arr[i] = ipar();
        }
        return arr;
    }

    public long lpar()
    { String test=tok.nextToken();
      if(test==null || test.trim().length()==0)
    	  return 0;
        return Long.parseLong(test);
    }

    public long[] lapar(int n)
    {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++)
        {
            arr[i] = lpar();
        }
        return arr;
    }

    public double dpar()
    {
        return Double.parseDouble(tok.nextToken());
    }

    public String spar()
    { String test=tok.nextToken();
      if(test==null || test.trim().length()==0)
    	  return "";
        return test;
    }

    public static void main(String[] args) throws java.lang.Exception
    {
        new second().go();
    }

    static class pair {
    	int single;int leaf;int claw;int prev;
    	public pair(int a,int b,int c,int d)
    	{
    		single=a;leaf=b;claw=c;
    		prev=d;
    	}
    }

}


#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long
int main()
{
	ll int dp[2000001]={};
	dp[0]=0;
	dp[1]=0;
	dp[2]=0;
	for(int i=3;i<=2000000;i++)
	{
		dp[i]=2*dp[i-2]+dp[i-1];
		if(i%3==0)
		dp[i]+=4;
		dp[i]%=M;
	}
	int t;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		cout<<dp[n]<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long
int main()
{
	ll int dp[2000001]={};
	dp[0]=0;
	dp[1]=0;
	dp[2]=0;
	for(int i=3;i<=2000000;i++)
	{
		dp[i]=2*dp[i-2]+dp[i-1];
		if(i%3==0)
		dp[i]+=1;
		dp[i]%=M;
	}
	int t;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		cout<<dp[n]<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
int main()
{
	int dp[2000001]={};
	for(int i=3;i<=2000000;i++)
	{
		dp[i]=2*dp[i-2]+dp[i-1];
		if(i%3==0)
		dp[i]+=1;
		dp[i]%=M;
	}
	int t;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		cout<<dp[n]<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
int main()
{
	int dp[1000001]={};
	for(int i=3;i<=1000000;i++)
	{
		if(i%3==0)
		dp[i]=1;
		dp[i]+=2*dp[i-2]+dp[i-1];
		dp[i]%=M;
	}
	int t;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		cout<<dp[n]<<endl;
	}
}


#include<bits/stdc++.h>
  // #include <ext/pb_ds/assoc_container.hpp>
  // #include <ext/pb_ds/tree_policy.hpp>
  #define ll  long long
  #define ld long double
  #define mod ((int)1e9+7)
  #define pb push_back
  #define ins insert
  #define F first
  #define S second
  #define ins insert
  #define pii pair <int , int>
  #define lb lower_bound
  #define ub upper_bound
  #define usefile freopen("input.txt","r",stdin); freopen("ou(tp)ut.txt","w",stdout);
  #define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define test int t; cin >> t; while(t--)
  #define all(x) (x).begin(), (x).end()
  #define rall(x) (x).rbegin(), (x).rend()
  int exp(int x,int y,int p){ int res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
  int expo(int x,int y){ int res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
  int add(ll a, ll b) {return (a%mod + b%mod + mod)%mod;}
  int sub(int a, int b) {return (a%mod - b%mod + mod)%mod;}
  int mul(int a, int b) {return ((a%mod)*(b%mod) + mod)%mod;}
  int inv(int x) {return expo(x, mod-2);}
  #define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
  // int sv[2000006]={0};
  // int fact[1000006]={0};
  // void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000006;i++)fact[i]=(fact[i-1]*i)%mod;}
  // void sve() {sv[0]=1;sv[1]=1;for(int i=2;i*i<maxx;i++){if(!sv[i]){for(int j=i*i;j<maxx;j+=i)sv[j]=1;}}}//0 hai to prime
  // int ncr(int n,int r) {int res=1; res=fact[n]; res=(res*(expo(fact[r],mod-2)))%mod; res=(res*(expo(fact[n-r],mod-2)))%mod; return res;}
  // int npr(int n,int r) {int res=1; res=fact[n]; res=(res*(expo(fact[n-r],mod-2)))%mod; return res;}
  // using namespace __gnu_pbds;
  // #define p_set tree< pair<int,int> ,  null_type ,  less<pair<int,int>> ,  rb_tree_tag ,  tree_order_statistics_node_update>
  // #define i_set tree< int ,  null_type ,  less< int > ,  rb_tree_tag ,  tree_order_statistics_node_update>
  using namespace std;
  // #define N 1000006
  vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
      res.push_back(s.substr(0, s.find(',')));
      s = s.substr(s.find(',') + 1);
    }
    return res;
  }
  void debug_out(
  vector<string> __attribute__ ((unused)) args,
  __attribute__ ((unused)) int idx,
  __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
  template <typename Head, typename... Tail>
  void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
  }
  #ifdef XOX
  #define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
  #else
  #define debug(...) 42
  #endif

     vector<int>dp(2000002,0);

  int main()
  {
    fast
    test{
     ll n;
     cin>>n;

     for(int i=3;i<=n;i++){
       dp[i]=add(dp[i-1],2*dp[i-2]);
       if(i%3==0)dp[i]=add(dp[i],4);

     }
     cout<<dp[n]<<"\n";

    }

    }


#include<bits/stdc++.h>
  // #include <ext/pb_ds/assoc_container.hpp>
  // #include <ext/pb_ds/tree_policy.hpp>
  #define ll  long long
  #define ld long double
  #define mod ((int)1e9+7)
  #define pb push_back
  #define ins insert
  #define F first
  #define S second
  #define ins insert
  #define pii pair <int , int>
  #define lb lower_bound
  #define ub upper_bound
  #define usefile freopen("input.txt","r",stdin); freopen("ou(tp)ut.txt","w",stdout);
  #define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define test int t; cin >> t; while(t--)
  #define all(x) (x).begin(), (x).end()
  #define rall(x) (x).rbegin(), (x).rend()
  int exp(int x,int y,int p){ int res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
  int expo(int x,int y){ int res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
  int add(ll a, ll b) {return (a%mod + b%mod + mod)%mod;}
  int sub(int a, int b) {return (a%mod - b%mod + mod)%mod;}
  int mul(int a, int b) {return ((a%mod)*(b%mod) + mod)%mod;}
  int inv(int x) {return expo(x, mod-2);}
  #define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
  // int sv[2000006]={0};
  // int fact[1000006]={0};
  // void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000006;i++)fact[i]=(fact[i-1]*i)%mod;}
  // void sve() {sv[0]=1;sv[1]=1;for(int i=2;i*i<maxx;i++){if(!sv[i]){for(int j=i*i;j<maxx;j+=i)sv[j]=1;}}}//0 hai to prime
  // int ncr(int n,int r) {int res=1; res=fact[n]; res=(res*(expo(fact[r],mod-2)))%mod; res=(res*(expo(fact[n-r],mod-2)))%mod; return res;}
  // int npr(int n,int r) {int res=1; res=fact[n]; res=(res*(expo(fact[n-r],mod-2)))%mod; return res;}
  // using namespace __gnu_pbds;
  // #define p_set tree< pair<int,int> ,  null_type ,  less<pair<int,int>> ,  rb_tree_tag ,  tree_order_statistics_node_update>
  // #define i_set tree< int ,  null_type ,  less< int > ,  rb_tree_tag ,  tree_order_statistics_node_update>
  using namespace std;
  // #define N 1000006
  vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
      res.push_back(s.substr(0, s.find(',')));
      s = s.substr(s.find(',') + 1);
    }
    return res;
  }
  void debug_out(
  vector<string> __attribute__ ((unused)) args,
  __attribute__ ((unused)) int idx,
  __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
  template <typename Head, typename... Tail>
  void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
  }
  #ifdef XOX
  #define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
  #else
  #define debug(...) 42
  #endif

  int main()
  {
    test{
     ll n;
     cin>>n;
     vector<ll>dp(2000002,0);

     for(int i=3;i<=n;i++){
       dp[i]=add(dp[i-1],2*dp[i-2]);
       if(i%3==0)dp[i]=add(dp[i],4);

     }
     cout<<dp[n]<<"\n";

    }

    }


#include<bits/stdc++.h>
  // #include <ext/pb_ds/assoc_container.hpp>
  // #include <ext/pb_ds/tree_policy.hpp>
  #define ll  long long
  #define ld long double
  #define mod ((int)1e9+7)
  #define pb push_back
  #define ins insert
  #define F first
  #define S second
  #define ins insert
  #define pii pair <int , int>
  #define lb lower_bound
  #define ub upper_bound
  #define usefile freopen("input.txt","r",stdin); freopen("ou(tp)ut.txt","w",stdout);
  #define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define test int t; cin >> t; while(t--)
  #define all(x) (x).begin(), (x).end()
  #define rall(x) (x).rbegin(), (x).rend()
  int exp(int x,int y,int p){ int res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
  int expo(int x,int y){ int res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
  int add(ll a, ll b) {return (a%mod + b%mod + mod)%mod;}
  int sub(int a, int b) {return (a%mod - b%mod + mod)%mod;}
  int mul(int a, int b) {return ((a%mod)*(b%mod) + mod)%mod;}
  int inv(int x) {return expo(x, mod-2);}
  #define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
  // int sv[2000006]={0};
  // int fact[1000006]={0};
  // void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000006;i++)fact[i]=(fact[i-1]*i)%mod;}
  // void sve() {sv[0]=1;sv[1]=1;for(int i=2;i*i<maxx;i++){if(!sv[i]){for(int j=i*i;j<maxx;j+=i)sv[j]=1;}}}//0 hai to prime
  // int ncr(int n,int r) {int res=1; res=fact[n]; res=(res*(expo(fact[r],mod-2)))%mod; res=(res*(expo(fact[n-r],mod-2)))%mod; return res;}
  // int npr(int n,int r) {int res=1; res=fact[n]; res=(res*(expo(fact[n-r],mod-2)))%mod; return res;}
  // using namespace __gnu_pbds;
  // #define p_set tree< pair<int,int> ,  null_type ,  less<pair<int,int>> ,  rb_tree_tag ,  tree_order_statistics_node_update>
  // #define i_set tree< int ,  null_type ,  less< int > ,  rb_tree_tag ,  tree_order_statistics_node_update>
  using namespace std;
  // #define N 1000006
  vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
      res.push_back(s.substr(0, s.find(',')));
      s = s.substr(s.find(',') + 1);
    }
    return res;
  }
  void debug_out(
  vector<string> __attribute__ ((unused)) args,
  __attribute__ ((unused)) int idx,
  __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
  template <typename Head, typename... Tail>
  void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
  }
  #ifdef XOX
  #define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
  #else
  #define debug(...) 42
  #endif

     vector<ll>dp(2000002,0);

  int main()
  {
    fast
    test{
     ll n;
     cin>>n;

     for(int i=3;i<=n;i++){
       dp[i]=add(dp[i-1],2*dp[i-2]);
       if(i%3==0)dp[i]=add(dp[i],4);

     }
     cout<<dp[n]<<"\n";

    }

    }


#include<bits/stdc++.h>
  // #include <ext/pb_ds/assoc_container.hpp>
  // #include <ext/pb_ds/tree_policy.hpp>
  #define ll  long long
  #define ld long double
  #define mod ((int)1e9+7)
  #define pb push_back
  #define ins insert
  #define F first
  #define S second
  #define ins insert
  #define pii pair <int , int>
  #define lb lower_bound
  #define ub upper_bound
  #define usefile freopen("input.txt","r",stdin); freopen("ou(tp)ut.txt","w",stdout);
  #define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define test int t; cin >> t; while(t--)
  #define all(x) (x).begin(), (x).end()
  #define rall(x) (x).rbegin(), (x).rend()
  int exp(int x,int y,int p){ int res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
  int expo(int x,int y){ int res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
  int add(ll a, ll b) {return (a%mod + b%mod + mod)%mod;}
  int sub(int a, int b) {return (a%mod - b%mod + mod)%mod;}
  int mul(int a, int b) {return ((a%mod)*(b%mod) + mod)%mod;}
  int inv(int x) {return expo(x, mod-2);}
  #define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
  // int sv[2000006]={0};
  // int fact[1000006]={0};
  // void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000006;i++)fact[i]=(fact[i-1]*i)%mod;}
  // void sve() {sv[0]=1;sv[1]=1;for(int i=2;i*i<maxx;i++){if(!sv[i]){for(int j=i*i;j<maxx;j+=i)sv[j]=1;}}}//0 hai to prime
  // int ncr(int n,int r) {int res=1; res=fact[n]; res=(res*(expo(fact[r],mod-2)))%mod; res=(res*(expo(fact[n-r],mod-2)))%mod; return res;}
  // int npr(int n,int r) {int res=1; res=fact[n]; res=(res*(expo(fact[n-r],mod-2)))%mod; return res;}
  // using namespace __gnu_pbds;
  // #define p_set tree< pair<int,int> ,  null_type ,  less<pair<int,int>> ,  rb_tree_tag ,  tree_order_statistics_node_update>
  // #define i_set tree< int ,  null_type ,  less< int > ,  rb_tree_tag ,  tree_order_statistics_node_update>
  using namespace std;
  // #define N 1000006
  vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
      res.push_back(s.substr(0, s.find(',')));
      s = s.substr(s.find(',') + 1);
    }
    return res;
  }
  void debug_out(
  vector<string> __attribute__ ((unused)) args,
  __attribute__ ((unused)) int idx,
  __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
  template <typename Head, typename... Tail>
  void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
  }
  #ifdef XOX
  #define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
  #else
  #define debug(...) 42
  #endif

     vector<int>dp(2000002,0);

  int main()
  { fast;
    for(int i=3;i<=2000000;i++){
       dp[i]=add(dp[i-1],2*dp[i-2]);
       if(i%3==0)dp[i]=add(dp[i],4);

     }

    test{
     ll n;
     cin>>n;

     cout<<dp[n]<<"\n";

    }

    }


#include<bits/stdc++.h>
  // #include <ext/pb_ds/assoc_container.hpp>
  // #include <ext/pb_ds/tree_policy.hpp>
  #define ll  long long
  #define ld long double
  #define mod ((int)1e9+7)
  #define pb push_back
  #define ins insert
  #define F first
  #define S second
  #define ins insert
  #define pii pair <int , int>
  #define lb lower_bound
  #define ub upper_bound
  #define usefile freopen("input.txt","r",stdin); freopen("ou(tp)ut.txt","w",stdout);
  #define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define test int t; cin >> t; while(t--)
  #define all(x) (x).begin(), (x).end()
  #define rall(x) (x).rbegin(), (x).rend()
  int exp(int x,int y,int p){ int res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
  int expo(int x,int y){ int res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
  int add(ll a, ll b) {return (a%mod + b%mod + mod)%mod;}
  int sub(int a, int b) {return (a%mod - b%mod + mod)%mod;}
  int mul(int a, int b) {return ((a%mod)*(b%mod) + mod)%mod;}
  int inv(int x) {return expo(x, mod-2);}
  #define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
  // int sv[2000006]={0};
  // int fact[1000006]={0};
  // void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000006;i++)fact[i]=(fact[i-1]*i)%mod;}
  // void sve() {sv[0]=1;sv[1]=1;for(int i=2;i*i<maxx;i++){if(!sv[i]){for(int j=i*i;j<maxx;j+=i)sv[j]=1;}}}//0 hai to prime
  // int ncr(int n,int r) {int res=1; res=fact[n]; res=(res*(expo(fact[r],mod-2)))%mod; res=(res*(expo(fact[n-r],mod-2)))%mod; return res;}
  // int npr(int n,int r) {int res=1; res=fact[n]; res=(res*(expo(fact[n-r],mod-2)))%mod; return res;}
  // using namespace __gnu_pbds;
  // #define p_set tree< pair<int,int> ,  null_type ,  less<pair<int,int>> ,  rb_tree_tag ,  tree_order_statistics_node_update>
  // #define i_set tree< int ,  null_type ,  less< int > ,  rb_tree_tag ,  tree_order_statistics_node_update>
  using namespace std;
  // #define N 1000006
  vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
      res.push_back(s.substr(0, s.find(',')));
      s = s.substr(s.find(',') + 1);
    }
    return res;
  }
  void debug_out(
  vector<string> __attribute__ ((unused)) args,
  __attribute__ ((unused)) int idx,
  __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
  template <typename Head, typename... Tail>
  void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
  }
  #ifdef XOX
  #define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
  #else
  #define debug(...) 42
  #endif

     vector<ll>dp(2000002,0);

  int main()
  {
    test{
     ll n;
     cin>>n;

     for(int i=3;i<=n;i++){
       dp[i]=add(dp[i-1],2*dp[i-2]);
       if(i%3==0)dp[i]=add(dp[i],4);

     }
     cout<<dp[n]<<"\n";

    }

    }


#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define INF 1000000000000000
#define ff first
#define ss second
#define mod 1000000007
#define endl "\n"
#define BS binary_search
#define N 2000005
int dp[N];
int dp2[N];
int ans[N];
void pre2(){
	dp2[0]=0;
	dp2[1]=1;
	dp2[2]=1;
	dp2[3]=3;
	for(int i=4;i<N;i++){
		dp2[i]=(dp2[i-1]+2*dp2[i-2])%mod;
	}
}
void pre(){
	pre2();
	dp[0]=0;
	dp[1]=0;
	dp[2]=0;
	dp[3]=1;
	for(int i=4;i<N;i++){
		dp[i]=(dp[i-1]+dp2[i-2])%mod;
	}
}
void pre3(){
	pre2();
	pre();
	ans[0]=0;
	ans[1]=0;
	ans[2]=0;
	ans[3]=4;
	for(int i=4;i<N;i++){
		ans[i]=(ans[i-3]+(dp[i]-dp[i-1])*4)%mod;
	}
}
void solve()
{

	pre3();
	int n;cin>>n;
	cout<<ans[n]%mod<<endl;
}
int32_t main()
{
	IOS;
	#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
   	int tc=1;
   	cin>>tc;
   	while(tc--){
   		solve();
   	}
}


#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define INF 1000000000000000
#define ff first
#define ss second
#define mod 1000000007
#define endl "\n"
#define BS binary_search
#define N 2000005
int dp[N];
int dp2[N];
int ans[N];
void pre2(){
	dp2[0]=0;
	dp2[1]=1;
	dp2[2]=1;
	dp2[3]=3;
	for(int i=4;i<N;i++){
		dp2[i]=(dp2[i-1]+2*dp2[i-2])%mod;
	}
}
void pre(){
	pre2();
	dp[0]=0;
	dp[1]=0;
	dp[2]=0;
	dp[3]=1;
	for(int i=4;i<N;i++){
		dp[i]=(dp[i-1]+dp2[i-2])%mod;
	}
}
void pre3(){
	pre2();
	pre();
	ans[0]=0;
	ans[1]=0;
	ans[2]=0;
	ans[3]=4;
	for(int i=4;i<N;i++){
		ans[i]=(ans[i-3]+(dp[i]-dp[i-1])*4)%mod;
	}
}
void solve()
{

	pre3();
	int n;cin>>n;
	if(ans[n]%mod<0){
	    cout<<ans[n]%mod+mod<<endl;
	    return;
	}
	cout<<ans[n]%mod<<endl;
}
int32_t main()
{
	IOS;
	#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
   	int tc=1;
   	cin>>tc;
   	pre3();
   	while(tc--){

	    int n;cin>>n;
	    if(ans[n]%mod<0){
	        cout<<ans[n]%mod+mod<<endl;
	        break;
	    }
	    cout<<ans[n]%mod<<endl;
   	}
}


#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define INF 1000000000000000
#define ff first
#define ss second
#define mod 1000000007
#define endl "\n"
#define BS binary_search
#define N 2000005
int dp[N];
int dp2[N];
int ans[N];
void pre2(){
	dp2[0]=0;
	dp2[1]=1;
	dp2[2]=1;
	dp2[3]=3;
	for(int i=4;i<N;i++){
		dp2[i]=(dp2[i-1]+2*dp2[i-2])%mod;
	}
}
void pre(){
	pre2();
	dp[0]=0;
	dp[1]=0;
	dp[2]=0;
	dp[3]=1;
	for(int i=4;i<N;i++){
		dp[i]=(dp[i-1]+dp2[i-2])%mod;
	}
}
void pre3(){
	pre2();
	pre();
	ans[0]=0;
	ans[1]=0;
	ans[2]=0;
	ans[3]=4;
	for(int i=4;i<N;i++){
		ans[i]=(ans[i-3]+(dp[i]-dp[i-1])*4)%mod;
	}
}
void solve()
{

	pre3();
	int n;cin>>n;
	if(ans[n]%mod<0){
	    cout<<ans[n]%mod+mod<<endl;
	    return;
	}
	cout<<ans[n]%mod<<endl;
}
int32_t main()
{
	IOS;
	#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
   	int tc=1;
   	cin>>tc;
   	pre3();
   	while(tc--){

	    int n;cin>>n;
	    if(ans[n]%mod<0){
	        cout<<ans[n]%mod+mod<<endl;
	        continue;
	    }
	    cout<<ans[n]%mod<<endl;
   	}
}


#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define INF 1000000000000000
#define ff first
#define ss second
#define mod 1000000007
#define endl "\n"
#define BS binary_search
#define N 2000005
int dp[N];
int dp2[N];
int ans[N];
void pre2(){
	dp2[0]=0;
	dp2[1]=1;
	dp2[2]=1;
	dp2[3]=3;
	for(int i=4;i<N;i++){
		dp2[i]=(dp2[i-1]+2*dp2[i-2])%mod;
	}
}
void pre(){
	pre2();
	dp[0]=0;
	dp[1]=0;
	dp[2]=0;
	dp[3]=1;
	for(int i=4;i<N;i++){
		dp[i]=(dp[i-1]+dp2[i-2])%mod;
	}
}
void pre3(){
	pre2();
	pre();
	ans[0]=0;
	ans[1]=0;
	ans[2]=0;
	ans[3]=4;
	for(int i=4;i<N;i++){
		ans[i]=(ans[i-3]+(dp[i]-dp[i-1])*4)%mod;
	}
}
void solve()
{

	pre3();
	int n;cin>>n;
	if(ans[n]%mod<0){
	    cout<<ans[n]%mod+mod<<endl;
	}
	cout<<ans[n]%mod<<endl;
}
int32_t main()
{
	IOS;
	#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
   	int tc=1;
   	cin>>tc;
   	while(tc--){
   		solve();
   	}
}


#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define INF 1000000000000000
#define ff first
#define ss second
#define mod 1000000007
#define endl "\n"
#define BS binary_search
#define N 2000005
int dp[N];
int dp2[N];
int ans[N];
void pre2(){
	dp2[0]=0;
	dp2[1]=1;
	dp2[2]=1;
	dp2[3]=3;
	for(int i=4;i<N;i++){
		dp2[i]=(dp2[i-1]+2*dp2[i-2])%mod;
	}
}
void pre(){
	pre2();
	dp[0]=0;
	dp[1]=0;
	dp[2]=0;
	dp[3]=1;
	for(int i=4;i<N;i++){
		dp[i]=(dp[i-1]+dp2[i-2])%mod;
	}
}
void pre3(){
	pre2();
	pre();
	ans[0]=0;
	ans[1]=0;
	ans[2]=0;
	ans[3]=4;
	for(int i=4;i<N;i++){
		ans[i]=(ans[i-3]+(dp[i]-dp[i-1])*4)%mod;
	}
}
void solve()
{

	pre3();
	int n;cin>>n;
	if(ans[n]%mod<0){
	    cout<<ans[n]%mod+mod<<endl;
	    return;
	}
	cout<<ans[n]%mod<<endl;
}
int32_t main()
{
	IOS;
	#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
   	int tc=1;
   	cin>>tc;
   	while(tc--){
   		solve();
   	}
}


#include<bits/stdc++.h>
#define ll long long
#define pi acos(-1)
#define mst(a,i) memset(a,i,sizeof(a))
using namespace std;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll maxn=2e6+5;
const ll mod=1e9+7;

ll a[maxn],n,ans[maxn];
void init(ll n){
	a[1]=a[2]=1;
	for(ll i=3;i<=n;i++) a[i]=(a[i-1]+2*a[i-2])%mod;
	//printf("a[%lld]=%lld\n",i,a[i]);
	ans[1]=ans[2]=0,ans[3]=1;
	for(ll i=4;i<=n;i++) ans[i]=(ans[i-3]+a[i-2])%mod;
	return ;
}
int main(){
    ios::sync_with_stdio(false);
    int T=1;
    init(2e6);
    cin>>T;
    while(T--){
    	cin>>n;
    	//cout<<">>>";
    	ll x=ans[n]*4%mod;
		cout<<x<<endl;
    }
    return 0;
}
/*
10000
1999992
1999998
2000000
1999998
wrong answer 4th numbers differ - expected: '201166296', found: '804665184'
*/


#include<bits/stdc++.h>
#define ll long long
#define pi acos(-1)
#define mst(a,i) memset(a,i,sizeof(a))
using namespace std;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll maxn=2e6+5;
const ll mod=1e9+7;

ll a[maxn],n;
void init(ll n){
	a[1]=a[2]=1;
	for(ll i=3;i<=n;i++) a[i]=(a[i-1]+2*a[i-2])%mod;
	//printf("a[%lld]=%lld\n",i,a[i]);
	return ;
}
int main(){
    ios::sync_with_stdio(false);
    int T=1;
    init(2e6);
    cin>>T;
    while(T--){
    	cin>>n;
    	ll ans=0;
    	for(ll i=n-2;i>=1;i-=3) ans=(ans+a[i])%mod;
    	//cout<<">>>";
    	ans=ans*4%mod;
		cout<<ans<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define pi acos(-1)
#define mst(a,i) memset(a,i,sizeof(a))
using namespace std;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll maxn=2e6+5;
const ll mod=1e9+7;

ll a[maxn],n;
void init(ll n){
	a[1]=a[2]=1;
	for(ll i=3;i<=n;i++) a[i]=(a[i-1]+2*a[i-2])%mod;
	//printf("a[%lld]=%lld\n",i,a[i]);
	return ;
}
int main(){
    ios::sync_with_stdio(false);
    int T=1;
    init(2e6);
    cin>>T;
    while(T--){
    	cin>>n;
    	ll ans=0;
    	for(ll i=n-2;i>=1;i-=3) ans=(ans+a[i])%mod;
    	cout<<">>>";
    	ans=ans*4%mod;
		cout<<ans<<endl;
    }
    return 0;
}
//˼ά֮ǿ�����ò�����һ����Ŀ��Ȼ���Ա����˼򵥣�����


#include<bits/stdc++.h>
#define ll long long
#define pi acos(-1)
#define mst(a,i) memset(a,i,sizeof(a))
using namespace std;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll maxn=2e6+5;
const ll mod=1e9+7;

ll a[maxn],n,ans[maxn];
void init(ll n){
	a[1]=a[2]=1;
	for(ll i=3;i<=n;i++) a[i]=(a[i-1]+2*a[i-2])%mod;
	//printf("a[%lld]=%lld\n",i,a[i]);
	ans[1]=ans[2]=0,ans[3]=1;
	for(ll i=1;i<=n;i++) ans[i+2]=(ans[i+2-3]+a[i])%mod;
	return ;
}
int main(){
    ios::sync_with_stdio(false);
    int T=1;
    init(2e6);
    cin>>T;
    while(T--){
    	cin>>n;
    	//cout<<">>>";
    	ans[n]=ans[n]*4%mod;
		cout<<ans[n]<<endl;
    }
    return 0;
}
//˼ά֮ǿ�����ò�����һ����Ŀ��Ȼ���Ա����˼򵥣�����


#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int MOD = 1e9+7;

  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<vector<long long>> dp(n+1, vector<long long>(2,0));
    if (n <= 4) {
      if (n <= 2) cout << "0\n";
      else cout << "4\n";
    } else {
      dp[3][1] = 4;
      dp[3][0] = 0;
      dp[4][0] = 4;
      dp[4][1] = 4;
      for (int i = 5; i <= n; ++i) {
        dp[i][1] = (4 + dp[i-1][0] + (2*dp[i-2][0])%MOD)%MOD;
        dp[i][0] = (max(dp[i-1][1],dp[i-1][0]) + (2*max(dp[i-2][0], dp[i-2][1]))%MOD)%MOD;
      }
      cout << max(dp[n][0], dp[n][1]) << '\n';
    }
  }

  return 0;
}

// multiplication -> long long
// careful arithmetic


#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int MOD = 1e9+7;

  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<vector<long long>> dp(n+1, vector<long long>(2,0));
    if (n <= 4) {
      if (n <= 2) cout << "0\n";
      else cout << "4\n";
    } else {
      dp[3][1] = 4;
      dp[3][0] = 0;
      dp[4][0] = 4;
      dp[4][1] = 4;
      for (int i = 5; i <= n; ++i) {
        dp[i][1] = (4 + dp[i-1][0] + (2*dp[i-2][0])%MOD)%MOD;
        long long tmp = 0;
        for (int a = 0; a < 2; ++a) {
          for (int b = 0; b < 2; ++b) {
            for (int c = 0; c < 2; ++c) {
              long long cur = (dp[i-1][a] + dp[i-2][b] + dp[i-2][c])%MOD;
              if (cur > tmp) tmp = cur;
            }
          }
        }
        dp[i][0] = max(dp[i][0], tmp);
      }
      cout << max(dp[n][0], dp[n][1]) << '\n';
    }
  }

  return 0;
}

// multiplication -> long long
// careful arithmetic


#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int MOD = 1e9+7;

  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<vector<long long>> dp(n+1, vector<long long>(2,0));
    if (n <= 4) {
      if (n <= 2) cout << "0\n";
      else cout << "4\n";
    } else {
      dp[3][1] = 4;
      dp[3][0] = 0;
      dp[4][0] = 4;
      dp[4][1] = 4;
      for (int i = 5; i <= n; ++i) {
        dp[i][1] = (4 + dp[i-1][0] + (2*dp[i-2][0])%MOD)%MOD;
        long long tmp = 0;
        for (int a = 0; a < 2; ++a) {
          for (int b = 0; b < 2; ++b) {
            for (int c = 0; c < 2; ++c) {
              long long cur = dp[i-1][a] + dp[i-2][b] + dp[i-2][c];
              while (cur > MOD) cur -= MOD;
              if (cur > tmp) tmp = cur;
            }
          }
        }
        dp[i][0] = max(dp[i][0], tmp);
      }
      cout << max(dp[n][0], dp[n][1]) << '\n';
    }
  }

  return 0;
}

// multiplication -> long long
// careful arithmetic


#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int MOD = 1e9+7;

  int t;
  cin >> t;
  vector<vector<long long>> dp(2e6+1, vector<long long>(2,0));
  dp[3][1] = 4;
  dp[3][0] = 0;
  dp[4][0] = 4;
  dp[4][1] = 4;
  for (int i = 5; i <= 2e6; ++i) {
    dp[i][1] = (4 + dp[i-1][0] + (2*dp[i-2][0])%MOD)%MOD;
    dp[i][0] = (max(dp[i-1][1],dp[i-1][0]) + (2*max(dp[i-2][0], dp[i-2][1]))%MOD)%MOD;
  }
  while (t--) {
    int n;
    cin >> n;
    if (n <= 4) {
      if (n <= 2) cout << "0\n";
      else cout << "4\n";
    } else {
      cout << max(dp[n][0], dp[n][1]) << '\n';
    }
  }

  return 0;
}

// multiplication -> long long
// careful arithmetic