Not so Easy Maths WA on Test cases

Getting WA in test cases and Correct Ans on samples test cases please help

#include<bits/stdc++.h>
using namespace std;
#define fo(i, n) for(int i=0;i<n;i++)

#define Fo(i, k, n) for(int i=k; i<n;i++)

#define ll long long int

#define ALL© ©.begin(),©.end() //handy for function like “sort()”

#define mod 1000000007

#define ff first

#define ss second

typedef vector vi;

typedef vector vvi;

typedef vector vli ;

typedef pair<int, int> pii ;

ll func(ll n , vi &v, int a) {

  ll cnt = 0 ;

  ll val = 1 ;

  int i = 0 ;

   while(a) {

        int last_bit = (a&1) ;

        if(last_bit) {

              cnt ++ ;

              val *= v[i] ;

        }

        i++ ;

        a = a >> 1 ;

  }

  ll final = n/val ;



  if(cnt&1) {

        return final ;

  }else {

        return (final - 2*final) ;

  }

}

int main() {

  ios_base::sync_with_stdio(false);

  cin.tie(NULL);

    int t ;

    t = 1 ;

    cin >> t ;  

    while(t--){

       ll n ;

       cin >> n ;

       vi v = {2, 3, 5, 7, 11, 13, 17 , 19} ;

       ll total = (1<<8 -1) ;

       ll ans = 0 ;

       Fo(i, 1, total) {

             ans += func(n, v, i) ;

       }

       cout << ans << "\n" ;


  }

}