import java.io.*;
public class Main {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
static StreamTokenizer sk = new StreamTokenizer(br);
static int MOD = (int)1e9 + 7;
public static void main(String[] args) throws Exception {
int T = nextInt();
for (int cases = 0; cases < T; cases ++ ) {
long n = nextLong();
long maxh = 0;
while ((1L << maxh) - 1 <= n) {
maxh ++ ;
}
maxh -- ;
long ans = 0L;
for (long i = 1L; i <= maxh; i ++ ) {
ans = (ans + (maxh - i + 1) * (1L << (i - 1))) % MOD;
}
long a = 1L;
long surplus = n - ((1L << maxh) - 1);
while (surplus != 0) {
if ((surplus & 1) != 0) {
ans = (ans + (a << 1) - 1) % MOD;
}
a = (a << 1) % MOD;
surplus >>= 1;
}
pw.println(ans);
}
pw.flush();
}
static int nextInt() throws Exception {
sk.nextToken();
return (int)sk.nval;
}
static long nextLong() throws Exception {
sk.nextToken();
return (long) sk.nval;
}
static String nextString() throws Exception {
sk.nextToken();
return sk.sval;
}
}