No worries, Found what was wrong It was just comparison in the while loop
while(!pq.empty() && pq.top().first <= v[i])
Here, value of v[i] can get smaller than first value of priority queue, because of using mod on v[i], to get the correct answer, I needed to compare that with complete value without modding it
Changed it to this
while(!pq.empty() && (cnt > 32 || pq.top().first <= sa*(1ll << cnt)))
And it worked, though priority queue gave a TLE