Showing TLE but i have used Sieve of eratosthenes

package ChallengeFundamentalPattern;
import java.io.;
import java.util.
;
public class PrateekLovesCandy
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
long a[]= new long[1000001];
Arrays.fill(a, 0);
int n,t;
t=sc.nextInt();
while(t>0)
{
int count=0;
n=sc.nextInt();
for(int i=3;i<1000000;i+=2)
{
a[i]=1;
}
for(int i=3;ii<1000000;i+=1)
{
if(a[i]==1)
{
for(int j=2;i
j<1000000;j+=1)
{
a[i*j]=0;
}
}
}
a[0]=a[1]=0;
a[2]=1;
for(int i=0;i<1000000;i+=1)
{
if(a[i]==1)
{
count+=1;
if(count==n) {
System.out.println(i);
break;
}
}
}
t-=1;
}

		}

}

@abhay_091
please use ide.codingblocks.com to share your code from the next time.its very difficult to understand raw code .
consider your loop
for (int k = 3; k< 1000000; k += 1){
if (a[k] == 1){
for (int j = 2; j < 1000000; j += 1){
a[k * j] = 0;
}
}
}

for a[kj]=0 you are going for a[10000001000000] at some point which is out of bounds of a