I cant figure out problem in my code for inputs : 7 \n 1 1 1 3 3 3 2

#include <bits/stdc++.h>

using namespace std;

int main(){
int cnt[64] = {0}, n, no;
cin >> n;

for (int i=0; i < n; n++){
    cin >> no;
    //update count array by extracting bit
    int j =0;
    while ( no > 0){
        int last_bit = (no & 1);
        cnt[j] += last_bit;
        j++;
        no = no >> 1;
    }
} 
//iterate over the array
int p = 1;
int ans = 0;
for (int i=0; i < 64; i++){
    cnt[i] %= 3;
    ans += (cnt[i] *p);
    p = p << 1;
}

cout << ans << "\n";

return 0;

}

@adityakaunhai
hello Aditya,
use long long datatype because 64 bit numbers cannot fit in integer datatype.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.