Time limit error - Prateek loves candy

I am encountering TLE for one test case, while the others are passing.

#include
#define ll long
using namespace std;

ll seive(ll a[], ll n)
{

a[2] = a[1] = 1;

for(ll i = 3; i<n; i+=2)
{
	a[i] = 1;
}

for(ll i = 3; i<n; i+=2)
{
	if(a[i] == 1)
	{
		for(ll j = i*i; j<n; j+=i)
		{
			a[j] = 0;
		}
	}
}

}

int main() {
int t;
cin>>t;

ll max = 1000000;
ll a[max] = {0};

seive(a,max);


while(t--)
{
	int x;
	cin>>x;

	ll count = 1;

	while(x)
	{
		if(a[count+1] == 1)
		{
			x--;
		}

		count++;
	}

	cout<<count<<endl;

}
return 0;

}

Avoid using unnecessary loops as it is increasing the complexity and is then giving TLE for large test cases.

Check this.

Got it.
Its much more efficient.