Positive Mex(MEXUM) lunchtime april

Please someone tell me my mistake in this code.

#include
#include <unordered_map>
#include<math.h>
#include <string.h>
#define mod 998244353
using namespace std;

int main() {
long long int po[1000005],a,T,N;
cin>>T;
po[0]=1;
for(int i=1;i<1000005;i++){
po[i]=(2*po[i-1])%mod;
}

while(T--){
 cin>>N;
 long long int A[N+2];
 memset(A,0,sizeof(A));
for(int i=0;i<N;i++){cin>>a; if(a<N+2) A[a]++;}

long long int product=1,sum=N-A[1],ans=0;
for(long long int i=1;i<=N+1;i++){
    ans+=(i*((product)*(po[sum]))%mod)%mod;
    sum-=A[i+1];
    product=(product*(po[A[i]]-1))%mod;
}
    cout<<ans<<endl;
}
return 0;

}

Link -> https://www.codechef.com/viewsolution/33349589