Getting wrong answer despite applying sieve , please help!

#include <bits/stdc++.h>
using namespace std;

long long int finalprime[100001];
bool prime[100001]={false};
void sieve(){
for(int i=2;ii<=100001;i++){
if(prime[i] == false){
for(int j=i
i;j<=100001;j=j+i){
prime[j]=true;
}
}
}
int count=0;
for(int i=2;i<=100001;i++){
if(prime[i] == false){
finalprime[count]=i;
count++;
}
}
}
int main() {
sieve();
long long int t;
cin>>t;
while(t!=0){
int index;
cin>>index;
cout<<finalprime[index-1]<<endl;
t–;
}
return 0;
}

//here’s my code, if you find any mistake please tell me!

@Himanish hey himanish your code need to be optimise more your code is falls on over large constraint you can refer this.