#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e6 + 50;
bool notPrime[N];
int a[N], ps[N], pcnt;
int main()
{
    /*for (ll i = 2; i < N; i++)
    {
        if (!notPrime[i])
            ps[pcnt++] = i;
        for (int j = 0; i * ps[j] < N && j < pcnt; j++)
            notPrime[i * ps[j]] = true;
    }*/
    for (ll i = 2; i < N; i++)
        if (!notPrime[i])
            for (ll j = i * i; j < N; j += i)
                notPrime[j] = true;
    for (int k = 1; k * 3 < N; k++)
        if (!notPrime[k * 3 + 7])
            a[k] = 1;
    for (int k = 1; k * 3 < N; k++)
        a[k] += a[k - 1];
    int T,n;
    scanf("%d", &T);
    while (T--)
    {
        scanf("%d", &n);
        printf("%d\n", a[n]);
    }
    return 0;
}
