/*

    Topics:
        -
        -

    From:
        -
*/

#include <bits/stdc++.h>

using namespace std;
#define DESYNC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define m0(x) memset((x), 0, sizeof(x))
#define m1(x) memset((x), -1, sizeof(x))

// #define DEBUG
#ifdef DEBUG
    #define debug(x) cout << x
#else
    #define debug(x) do {} while(0)
#endif

const int MOD = (1LL<<32LL);

typedef pair<int,int> ii;
typedef vector< int > vi;
typedef vector< ii > vii;

int _gcd(int a, int b) { return b == 0 ? a : _gcd(b, a%b); }
int gcd(int a, int b) { return _gcd(abs(a), abs(b)); }

bool isprime[1123456];
vector<int> primes;
void seg_sieve(int l, int r) {
    for(int i = l; i <= r; i++) isprime[i] = true;
    for(int pri : primes) {
        for(int i = l-l%pri+(l%pri?pri:0); i <= r; i+=pri) {
            isprime[i] = false;
        }
    }
    for(int i = l; i <= r; i++) {
        if(isprime[i]) {
            primes.push_back(i);
            for(int j = i+i; j <= r; j+=i) isprime[j] = false;
        }
    }
}

int A,B,C,D;

int f(int p) {
    int ans = 0;
    ans += (A*((p*p*p)%MOD))%MOD;
    ans += (B*((p*p)%MOD))%MOD;
    ans += (C*((p)%MOD))%MOD;
    ans += D;
    ans %= MOD;
    return ans;
}

int32_t main() {
    // DESYNC;

    int n;
    cin >> n >> A >> B >> C >> D;

    int l = 2, r;
    for(int l = 2; l <= n; l+=(int)1e6+1) {
        r = min(n, l + (int)1e6);
        seg_sieve(l, r);
    }

    int ans = 0;
    int freq;
    for(int pri : primes) {
        freq = 0;
        for(int aux = pri; aux <= n; aux*=pri) {
            freq += n/aux;
        }
        ans += (freq*f(pri))%MOD;
        ans %= MOD;
    }

    cout << ans << endl;
}


/*

    Topics:
        -
        -

    From:
        -
*/

#include <bits/stdc++.h>

using namespace std;
#define DESYNC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define m0(x) memset((x), 0, sizeof(x))
#define m1(x) memset((x), -1, sizeof(x))

// #define DEBUG
#ifdef DEBUG
    #define debug(x) cout << x
#else
    #define debug(x) do {} while(0)
#endif

const int MOD = (1LL<<32LL);

typedef pair<int,int> ii;
typedef vector< int > vi;
typedef vector< ii > vii;

int _gcd(int a, int b) { return b == 0 ? a : _gcd(b, a%b); }
int gcd(int a, int b) { return _gcd(abs(a), abs(b)); }

bitset<112345>isprime;
vector<int> primes;
vector<int> seg_primes;
void seg_sieve(int l, int r, bool save) {
    debug(l<<" "<<r<<endl);
    // for(int i = l; i <= r; i++) isprime[i-l] = true;
    isprime.set();
    seg_primes.clear();
    for(int pri : primes) {
        for(int i = l-l%pri+(l%pri?pri:0); i <= r; i+=pri) {
            isprime[i-l] = false;
        }
    }
    for(int i = l; i <= r; i++) {
        if(isprime[i-l]) {
            debug(i<<endl);
            seg_primes.push_back(i);
            for(int j = i+i; j <= r; j+=i) isprime[j-l] = false;
        }
    }
    if(save) {
        for(int pri : seg_primes) primes.push_back(pri);
    }
}

int A,B,C,D;

int f(int p) {
    int ans = 0;
    ans += (A*((p*p*p)%MOD))%MOD;
    ans += (B*((p*p)%MOD))%MOD;
    ans += (C*((p)%MOD))%MOD;
    ans += D;
    ans %= MOD;
    return ans;
}

int32_t main() {
    // DESYNC;

    int n;
    cin >> n >> A >> B >> C >> D;

    int ans = 0, freq;
    int l = 2, r = min(n, (int)1e5);
    seg_sieve(l, r, true);
    for(int pri : seg_primes) {
        debug(pri<<endl);
        freq = 0;
        for(int aux = pri; aux <= n; aux*=pri) {
            freq += n/aux;
        }
        ans += (freq*f(pri))%MOD;
        ans %= MOD;
    }
    for(int l = r+1; l <= n; l=r+1) {
        r = min(n, l + (int)1e5);
        seg_sieve(l, r, false);
        for(int pri : seg_primes) {
            debug(pri<<endl);
            freq = 0;
            for(int aux = pri; aux <= n; aux*=pri) {
                freq += n/aux;
            }
            ans += (freq*f(pri))%MOD;
            ans %= MOD;
        }
    }

    cout << ans << endl;
}


/*

    Topics:
        -
        -

    From:
        -
*/

#include <bits/stdc++.h>

using namespace std;
#define DESYNC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define m0(x) memset((x), 0, sizeof(x))
#define m1(x) memset((x), -1, sizeof(x))

// #define DEBUG
#ifdef DEBUG
    #define debug(x) cout << x
#else
    #define debug(x) do {} while(0)
#endif

const int MOD = (1LL<<32LL);

typedef pair<int,int> ii;
typedef vector< int > vi;
typedef vector< ii > vii;

int _gcd(int a, int b) { return b == 0 ? a : _gcd(b, a%b); }
int gcd(int a, int b) { return _gcd(abs(a), abs(b)); }

const int lim = 1123456;
bitset<lim+10>isprime;
vector<int> primes;
vector<int> seg_primes;

void seg_sieve(int l, int r, bool save) {
    isprime.set();
    seg_primes.clear();
    for(int pri : primes)
        for(int i = l-(l%pri)+(l%pri?pri:0); i <= r; i+=pri)
            isprime[i-l] = false;
    for(int i = l; i <= r; i++) {
        if(isprime[i-l]) {
            seg_primes.push_back(i);
            for(int j = i+i; j <= r; j+=i) isprime[j-l] = false;
        }
    }
    if(save)
        for(int pri : seg_primes) primes.push_back(pri);
}

int A,B,C,D;

int f(int p) {
    int ans = 0;
    ans += (A*((p*p*p)%MOD))%MOD;
    ans += (B*((p*p)%MOD))%MOD;
    ans += (C*((p)%MOD))%MOD;
    ans += D;
    ans %= MOD;
    return ans;
}

int32_t main() {
    // DESYNC;

    int n;
    cin >> n >> A >> B >> C >> D;

    int ans = 0, freq;
    int l = 2, r = min(n, l+lim);
    seg_sieve(l, r, true);
    for(int pri : seg_primes) {
        debug(pri<<endl);
        freq = 0;
        for(int aux = pri; aux <= n; aux*=pri) {
            freq += n/aux;
        }
        ans += (freq*f(pri))%MOD;
        ans %= MOD;
    }
    for(int l = r+1; l <= n; l=r+1) {
        r = min(n, l + lim);
        seg_sieve(l, r, false);
        for(int pri : seg_primes) {
            debug(pri<<endl);
            freq = 0;
            for(int aux = pri; aux <= n; aux*=pri) {
                freq += n/aux;
            }
            ans += (freq*f(pri))%MOD;
            ans %= MOD;
        }
    }

    cout << ans << endl;
}


/*

    Topics:
        -
        -

    From:
        -
*/

#include <bits/stdc++.h>

using namespace std;
#define DESYNC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define m0(x) memset((x), 0, sizeof(x))
#define m1(x) memset((x), -1, sizeof(x))

// #define DEBUG
#ifdef DEBUG
    #define debug(x) cout << x
#else
    #define debug(x) do {} while(0)
#endif

const int MOD = (1LL<<32LL);

typedef pair<int,int> ii;
typedef vector< int > vi;
typedef vector< ii > vii;

int _gcd(int a, int b) { return b == 0 ? a : _gcd(b, a%b); }
int gcd(int a, int b) { return _gcd(abs(a), abs(b)); }

bool isprime[112345];
vector<int> primes;
void seg_sieve(int l, int r) {
    debug(l<<" "<<r<<endl);
    for(int i = l; i <= r; i++) isprime[i-l] = true;
    for(int pri : primes) {
        for(int i = l-l%pri+(l%pri?pri:0); i <= r; i+=pri) {
            isprime[i-l] = false;
        }
    }
    debug(primes.size()<<endl<<endl);
    for(int i = l; i <= r; i++) {
        if(isprime[i-l]) {
            debug(i<<endl);
            primes.push_back(i);
            for(int j = i+i; j <= r; j+=i) isprime[j-l] = false;
        }
    }
}

int A,B,C,D;

int f(int p) {
    int ans = 0;
    ans += (A*((p*p*p)%MOD))%MOD;
    ans += (B*((p*p)%MOD))%MOD;
    ans += (C*((p)%MOD))%MOD;
    ans += D;
    ans %= MOD;
    return ans;
}

int32_t main() {
    // DESYNC;

    int n;
    cin >> n >> A >> B >> C >> D;

    int l = 2, r;
    for(int l = 2; l <= n; l+=(int)1e5+1) {
        r = min(n, l + (int)1e5);
        seg_sieve(l, r);
    }

    int ans = 0;
    int freq;
    for(int pri : primes) {
        debug(pri<<endl);
        freq = 0;
        for(int aux = pri; aux <= n; aux*=pri) {
            freq += n/aux;
        }
        ans += (freq*f(pri))%MOD;
        ans %= MOD;
    }

    cout << ans << endl;
}


#include <iostream>
#include <bitset>
using namespace std;

#define FOI(i, a, n) for(int i = int(a); i <= int(n); i++)

typedef long long ll;
const int temp = 1e8 + 3;
const int te = 3e8 + 3;

bitset<temp> bi;
ll ans = 0;
int n;
int a,b,c,d;
ll mod = (1LL<<32)-1;

void solve(ll val)
{
    cout<<val<<" ";
    ll tmp = (val*val)&mod;
    ll fi = (d + c*val + b*tmp + a*((tmp*val)&mod))&mod;
    ll cur = val;
    while(cur <= n)
    {
        ans += fi*(n/cur);
        ans&=mod;
        cur*=val;
    }
}

void sieve()
{
    solve(2);
    solve(3);
    for(int i = 5;i<20000; i+=2)
    {

        if(bi[i/3]==0 && i%3!=0)
        {
            solve(i);
            for(int j=i*i; j<te-2; j+=2*i)
                if(j%3!=0)
                    bi[j/3] = 1;
        }
    }
    for(int i=20001;i<te-2; i+=2)
        if(bi[i/3]==0  && i%3!=0)
            solve(i);
}

int main()
{
    cin>>n;
    cin>>a>>b>>c>>d;
    //cout<<bi.size();
    sieve();
    cout<<ans<<endl;
}


#include <iostream>
#include <bitset>
using namespace std;

#define FOI(i, a, n) for(int i = int(a); i <= int(n); i++)

typedef long long ll;
const int temp = 1e8 + 3;
const int te = 3e8 + 3;

bitset<temp> bi;
ll ans = 0;
int n;
int a,b,c,d;
ll mod = (1LL<<32)-1;

void solve(ll val)
{
    // cout<<val<<" ";
    ll tmp = (val*val)&mod;
    ll fi = (d + c*val + b*tmp + a*((tmp*val)&mod))&mod;
    ll cur = val;
    while(cur <= n)
    {
        ans += fi*(n/cur);
        ans&=mod;
        cur*=val;
    }
}

void sieve()
{
    solve(2);
    solve(3);
    for(int i = 5;i<20000; i+=2)
    {

        if(bi[i/3]==0 && i%3!=0)
        {
            solve(i);
            for(int j=i*i; j<te-2; j+=2*i)
                if(j%3!=0)
                    bi[j/3] = 1;
        }
    }
    for(int i=20001;i<te-2; i+=2)
        if(bi[i/3]==0  && i%3!=0)
            solve(i);
}

int main()
{
    cin>>n;
    cin>>a>>b>>c>>d;
    //cout<<bi.size();
    sieve();
    cout<<ans<<endl;
}


#include <iostream>
#include <bitset>
using namespace std;

#define FOI(i, a, n) for(int i = int(a); i <= int(n); i++)

typedef long long ll;
const int temp = 1e8 + 3;

bitset<temp> bi;
ll ans = 0;
int n;
int a,b,c,d;
ll mod = (1LL<<32)-1;

void solve(ll val)
{
    ll tmp = (val*val)&mod;
    ll fi = (d + c*val + b*tmp + a*((tmp*val)&mod))&mod;
    ll cur = val;
    while(cur <= n)
    {
        ans += fi*(n/cur);
        ans&=mod;
        cur*=val;
    }
}

void sieve()
{
    solve(2);
    solve(3);
    for(int i = 5;i<20000; i+=2)
    {

        if(bi[i/3]==0)
        {
            solve(i);
            for(int j=i*i; j<temp-2; j+=i)
                bi[j/3] = 1;
        }
    }
    for(int i=20001;i<temp-2; i+=2)
        if(bi[i/3]==0)
            solve(i);
}

int main()
{
    cin>>n;
    cin>>a>>b>>c>>d;
    //cout<<bi.size();
    sieve();
    cout<<ans<<endl;
}


#include <iostream>
#include <bitset>
using namespace std;

#define FOI(i, a, n) for(int i = int(a); i <= int(n); i++)

typedef long long ll;
const int temp = 1e8 + 3;

bitset<temp> bi;
ll ans = 0;
int n;
int a,b,c,d;
ll mod = (1LL<<32)-1;

void solve(ll val)
{
    //cout<<val<<" ";
    ll tmp = (val*val)&mod;
    ll fi = (d + c*val + b*tmp + a*((tmp*val)&mod))&mod;
    ll cur = val;
    while(cur <= n)
    {
        ans += fi*(n/cur);
        ans&=mod;
        cur*=val;
    }
}

void sieve()
{
    solve(2);
    solve(3);
    for(int i = 5;i<20000; i+=2)
    {

        if(bi[i/3]==0 && i%3!=0)
        {
            solve(i);
            for(int j=i*i; j<temp-2; j+=2*i)
                if(j%3!=0)
                    bi[j/3] = 1;
        }
    }
    for(int i=20001;i<temp-2; i+=2)
        if(bi[i/3]==0  && i%3!=0)
            solve(i);
}

int main()
{
    cin>>n;
    cin>>a>>b>>c>>d;
    //cout<<bi.size();
    sieve();
    cout<<ans<<endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define pb push_back
#define f first
#define s second
#define mp make_pair
#define SZ(x) ((int)(x.size()))
#define FOI(i, a, n) for(int i = int(a); i <= int(n); i++)
#define FOD(i, a, n) for(int i = int(a); i >= int(n); i--)
#define IN(x, y) ((y).find(x) != (y).end())
#define ALL(t) t.begin(),t.end()
#define MSET(tabl,i) memset(tabl, i, sizeof(tabl))
#define PSET(x,y) fixed<<setprecision(y)<<lf(x)
#define DBG(c) cout << #c << " = " << c << endl;
#define RTIME ((double)clock()/(double)CLOCKS_PER_SEC)
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double lf;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
typedef vector < int > vi;
typedef vector<vi> vvi;
typedef complex<double> base;

const int N = 3e5 + 5;
const int lgN = 1e6+5;
const int temp = 3e8 + 3;
const ll MOD = 1e9 + 7;
const lf pi = 3.141592653589793238462643383;
const ll IMAX = -2e18;
const double PI = 3.141592653589793;

template<class T>
using max_pq = priority_queue<T>;
template<class T>
using min_pq = priority_queue<T,vector<T>,greater<T>>;
template<class T>
using OST = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ll x,y;
template<class T> T gcd(T a,T b){ if(a==0) {x=0,y=1; return b;}T gc=gcd(b%a,a);T temp;temp=x;x=y-(b/a)*temp;y=temp;return gc;}

//(a^x)%m
ll po(ll a, ll x,ll m){ if(x==0){return 1;}ll ans=1;ll k=1;  while(k<=x) {if(x&k){ans=((ans*a)%m);} k<<=1; a*=a; a%=m; }return ans; }

bitset<temp> bi;
ll ans = 0;
int n;
int a,b,c,d;
ll mod = (1LL<<32)-1;

void solve(ll val)
{
    ll tmp = (val*val)&mod;
    ll fi = (d + c*val + b*tmp + a*((tmp*val)&mod))&mod;
    ll cur = val;
    while(cur <= n)
    {
        ans += fi*(n/cur);
        ans&=mod;
        cur*=val;
    }
}

void sieve()
{
    solve(2);
    for(int i = 3;i<20000; i+=2)
    {
        if(bi[i]==0)
        {
            solve(i);
            for(int j=i*i; j<temp-2; j+=i)
                bi[j] = 1;
        }
    }
    for(int i=20001;i<temp-2; i+=2)
        if(bi[i]==0)
            solve(i);
}

int main()
{
    sync
    cin>>n;
    cin>>a>>b>>c>>d;
    //cout<<bi.size();
    sieve();
    cout<<ans<<endl;
}


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

const int MX = (int)1e8 + 5;

bitset<MX> flg;

void sieve(int n) {
	int x, y, z, t;
	for (z = 1; z <= 5; z += 4) {
		for (y = z; y * y <= n; y += 6) {
			for (x = 1; (t = 4 * x * x + y * y) <= n; x++) flg[t] = !flg[t];
			for (x = y + 1; (t = 3 * x * x - y * y) <= n; x += 2) flg[t] = !flg[t];
		}
	}
	for (z = 2; z <= 4; z += 2) {
		for (y = z; y * y <= n; y += 6) {
			for (x = 1; (t = 3 * x * x + y * y) <= n; x += 2) flg[t] = !flg[t];
			for (x = y + 1; (t = 3 * x * x - y * y) <= n; x += 2) flg[t] = !flg[t];
		}
	}
	for (y = 3; y * y <= n; y += 6) {
		for (z = 1; z <= 2; z++) {
			for (x = z; (t = 4 * x * x + y * y) <= n; x += 3) flg[t] = !flg[t];
		}
	}
	for (x = 5; x * x <= n; x++) {
		if (!flg[x]) continue;
		for (y = x * x; y <= n; y += x * x) flg[y] = 0;
	}
	flg[2] = flg[3] = 1;
}

int main() {

//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);

	ios_base::sync_with_stdio(false);

	sieve((int)1e8);

	int n;
	unsigned int A, B, C, D; cin >> n >> A >> B >> C >> D;
	unsigned int cur, ans = 0, cnt = 0;
	long long j;

	int lim = min(n, (int)1e8);

	for (int i = 2; i <= lim; i++) if (flg[i]) {
		cur = A * i * i * i + B * i * i + C * i + D;
		cnt = 0;
		for (j = i; j <= (long long)n; j *= i) cnt += n / (unsigned int)j;
		ans += cur * cnt;
	}

	if (n > (int)1e8) {
		for (int i = 0; i < MX; i++) flg[i] = 0;
		int jj;
		for (int i = 2; i * i <= (int)2e8; i++) {
			jj = (int)1e8 / i * i;
			if (jj <= (int)1e8) jj += i;
			if (flg[jj - (int)1e8]) continue;
			for (; jj <= (int)2e8; jj += i) flg[jj - (int)1e8] = 1;
		}

		lim = min(n, (int)2e8);
		for (int i = (int)1e8 + 1; i <= lim; i++) if (!flg[i - (int)1e8]) {
			cur = A * i * i * i + B * i * i + C * i + D;
			cnt = 0;
			for (j = i; j <= (long long)n; j *= i) cnt += n / (unsigned int)j;
			ans += cur * cnt;
		}
	}

	if (n > (int)2e8) {
		for (int i = 0; i < MX; i++) flg[i] = 0;
		int jj;
		for (int i = 2; i * i <= (int)3e8; i++) {
			jj = (int)2e8 / i * i;
			if (jj <= (int)2e8) jj += i;
			if (flg[jj - (int)2e8]) continue;
			for (; jj <= (int)3e8; jj += i) flg[jj - (int)2e8] = 1;
		}

		lim = min(n, (int)3e8);
		for (int i = (int)2e8 + 1; i <= lim; i++) if (!flg[i - (int)2e8]) {
			cur = A * i * i * i + B * i * i + C * i + D;
			cnt = 0;
			for (j = i; j <= (long long)n; j *= i) cnt += n / (unsigned int)j;
			ans += cur * cnt;
		}
	}

	cout << ans << endl;

	return 0;

}


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

const int MX = (int)1e8 + 5;

bitset<MX> flg;

void sieve(int n) {
	int x, y, z, t;
	for (z = 1; z <= 5; z += 4) {
		for (y = z; y * y <= n; y += 6) {
			for (x = 1; (t = 4 * x * x + y * y) <= n; x++) flg[t] = !flg[t];
			for (x = y + 1; (t = 3 * x * x - y * y) <= n; x += 2) flg[t] = !flg[t];
		}
	}
	for (z = 2; z <= 4; z += 2) {
		for (y = z; y * y <= n; y += 6) {
			for (x = 1; (t = 3 * x * x + y * y) <= n; x += 2) flg[t] = !flg[t];
			for (x = y + 1; (t = 3 * x * x - y * y) <= n; x += 2) flg[t] = !flg[t];
		}
	}
	for (y = 3; y * y <= n; y += 6) {
		for (z = 1; z <= 2; z++) {
			for (x = z; (t = 4 * x * x + y * y) <= n; x += 3) flg[t] = !flg[t];
		}
	}
	for (x = 5; x * x <= n; x++) {
		if (!flg[x]) continue;
		for (y = x * x; y <= n; y += x * x) flg[y] = 0;
	}
	flg[2] = flg[3] = 1;
}

int main() {

//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);

	ios_base::sync_with_stdio(false);

	sieve((int)1e8);

	int n;
	unsigned int A, B, C, D; cin >> n >> A >> B >> C >> D;
	unsigned int cur, ans = 0, cnt = 0;
	long long j;

	int lim = min(n, (int)1e8);

	for (int i = 2; i <= lim; i++) if (flg[i]) {
		cur = A * i * i * i + B * i * i + C * i + D;
		cnt = 0;
		for (j = i; j <= (long long)n; j *= i) cnt += n / (unsigned int)j;
		ans += cur * cnt;
	}

	if (n > (int)1e8) {
		for (int i = 0; i < MX; i++) flg[i] = 0;
		int jj;
		for (int i = 2; i * i <= (int)2e8; i++) {
			jj = (int)1e8 / i * i;
			if (jj <= (int)1e8) jj += i;
//			if (flg[jj - (int)1e8]) continue;
			for (; jj <= (int)2e8; jj += i) flg[jj - (int)1e8] = 1;
		}

		lim = min(n, (int)2e8);
		for (int i = (int)1e8 + 1; i <= lim; i++) if (!flg[i - (int)1e8]) {
			cur = A * i * i * i + B * i * i + C * i + D;
			cnt = 0;
			for (j = i; j <= (long long)n; j *= i) cnt += n / (unsigned int)j;
			ans += cur * cnt;
		}
	}

	if (n > (int)2e8) {
		for (int i = 0; i < MX; i++) flg[i] = 0;
		int jj;
		for (int i = 2; i * i <= (int)3e8; i++) {
			jj = (int)2e8 / i * i;
			if (jj <= (int)2e8) jj += i;
//			if (flg[jj - (int)2e8]) continue;
			for (; jj <= (int)3e8; jj += i) flg[jj - (int)2e8] = 1;
		}

		lim = min(n, (int)3e8);
		for (int i = (int)2e8 + 1; i <= lim; i++) if (!flg[i - (int)2e8]) {
			cur = A * i * i * i + B * i * i + C * i + D;
			cnt = 0;
			for (j = i; j <= (long long)n; j *= i) cnt += n / (unsigned int)j;
			ans += cur * cnt;
		}
	}

	cout << ans << endl;

	return 0;

}


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

const int MX = (int)3e8 + 5;

bitset<MX> flg;

void sieve(int n) {
	int x, y, z, t;
	for (z = 1; z <= 5; z += 4) {
		for (y = z; y * y <= n; y += 6) {
			for (x = 1; (t = 4 * x * x + y * y) <= n; x++) flg[t] = !flg[t];
			for (x = y + 1; (t = 3 * x * x - y * y) <= n; x += 2) flg[t] = !flg[t];
		}
	}
	for (z = 2; z <= 4; z += 2) {
		for (y = z; y * y <= n; y += 6) {
			for (x = 1; (t = 3 * x * x + y * y) <= n; x += 2) flg[t] = !flg[t];
			for (x = y + 1; (t = 3 * x * x - y * y) <= n; x += 2) flg[t] = !flg[t];
		}
	}
	for (y = 3; y * y <= n; y += 6) {
		for (z = 1; z <= 2; z++) {
			for (x = z; (t = 4 * x * x + y * y) <= n; x += 3) flg[t] = !flg[t];
		}
	}
	for (x = 5; x * x <= n; x++) {
		if (!flg[x]) continue;
		for (y = x * x; y <= n; y += x * x) flg[y] = 0;
	}
	flg[2] = flg[3] = 1;
}

int main() {

//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);

	ios_base::sync_with_stdio(false);

	sieve((int)3e8);

	unsigned int n, A, B, C, D; cin >> n >> A >> B >> C >> D;
	unsigned int cur, ans = 0, cnt = 0;

	for (int i = 2; i <= n; i++) if (flg[i]) {
		cur = A * i * i * i + B * i * i + C * i + D;
		cnt = 0;
		for (long long j = i; j <= (long long)n; j *= i) cnt += n / (unsigned int)j;
		ans += cur * cnt;
	}

	cout << ans << endl;

	return 0;

}


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

const int P = (int)1e8;
const int MX = P + 5;

bitset<MX> flg;
bool prime[(int)1e5 + 5];

void sieve(int n) {
	int x, y, z, t;
	for (z = 1; z <= 5; z += 4) {
		for (y = z; y * y <= n; y += 6) {
			for (x = 1; (t = 4 * x * x + y * y) <= n; x++) flg[t] = !flg[t];
			for (x = y + 1; (t = 3 * x * x - y * y) <= n; x += 2) flg[t] = !flg[t];
		}
	}
	for (z = 2; z <= 4; z += 2) {
		for (y = z; y * y <= n; y += 6) {
			for (x = 1; (t = 3 * x * x + y * y) <= n; x += 2) flg[t] = !flg[t];
			for (x = y + 1; (t = 3 * x * x - y * y) <= n; x += 2) flg[t] = !flg[t];
		}
	}
	for (y = 3; y * y <= n; y += 6) {
		for (z = 1; z <= 2; z++) {
			for (x = z; (t = 4 * x * x + y * y) <= n; x += 3) flg[t] = !flg[t];
		}
	}
	for (x = 5; x * x <= n; x++) {
		if (!flg[x]) continue;
		for (y = x * x; y <= n; y += x * x) flg[y] = 0;
	}
	flg[2] = flg[3] = 1;
}

int main() {

//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);

	ios_base::sync_with_stdio(false);

	sieve(P);
	for (int i = 2; i < (int)1e5; i++) prime[i] = flg[i];

	int n;
	unsigned int A, B, C, D; cin >> n >> A >> B >> C >> D;
	unsigned int cur, ans = 0, cnt = 0;
	long long j;

	int lim = min(n, P);

	for (int i = 2; i <= lim; i++) if (flg[i]) {
		cur = A * i * i * i + B * i * i + C * i + D;
		cnt = 0;
		for (j = i; j <= (long long)n; j *= i) cnt += n / (unsigned int)j;
		ans += cur * cnt;
	}

	for (int step = 1; step < 3; step++) if (n > step * P) {
		for (int i = 0; i < MX; i++) flg[i] = 0;
		int jj;
		for (int i = 2; (long long)i * i <= (long long)(step + 1) * P; i++) if (prime[i]) {
			jj = (step * P) / i * i;
			if (jj <= (step * P)) jj += i;
			for (; jj <= (step + 1) * P; jj += i) flg[jj - step * P] = 1;
		}

		lim = min(n, (step + 1) * P);
		for (int i = step * P + 1; i <= lim; i++) if (!flg[i - step * P]) {
			cur = A * i * i * i + B * i * i + C * i + D;
			cnt = 0;
			for (j = i; j <= (long long)n; j *= i) cnt += n / (unsigned int)j;
			ans += cur * cnt;
		}
	}

	cout << ans << endl;

	return 0;

}


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

#define fst first
#define snd second
#define mp make_pair
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define per(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()

template <typename T1, typename T2>
inline bool umin(T1& x, const T2& y){return x>y ? x=y,true : false;}

template <typename T1, typename T2>
inline bool umax(T1& x, const T2& y){return x<y ? x=y,true : false;}

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

const int N = (int)2e4+5;
const int mod = (int)1e9+7;
const int INF = (int)1e9+17;
const ll LLINF = (ll)1e18+17;

int n;
uint result;
uint A, B, C, D;

const uint BLOCK = (uint)1e4;
const uint SQRTMAX = (uint)2e4+1;

int prime[SQRTMAX];
bool block[BLOCK];
bool isprime[SQRTMAX];

int iPrime = 0;

inline uint f(uint p) {return A*p*p*p + B*p*p + C*p + D;}

inline void add(uint prime) {
    int power = 1;
    int64_t val = prime;
    while (val <= n) {
        ++power;
        val *= prime;
    }
    --power;
    val /= prime;
    int total = 0;
    while (power > 0) {
        result += (uint)(n / val - total) * power * f(prime);
        total += n / val - total;
        --power;
        val /= prime;
    }

}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    cin >> n >> A >> B >> C >> D;

    fill(isprime, isprime+SQRTMAX, true);
    isprime[0] = isprime[1] = false;
    for(int i = 2; i * i <= n; ++i) {
        if (!isprime[i]) continue;
        prime[iPrime++] = i;
        for(int j = i * i; j <= n; j += i) {
            isprime[j] = false;
        }
    }

    for(int bId = 0; ; ++bId) {
        int tl = bId * BLOCK, tr = min<int>(n+1, tl + BLOCK);
        fill(block, block+BLOCK, true);
        for(int i = 0; i < iPrime; ++i) {
            for(int bad = max(2, (tl + prime[i] - 1) / prime[i]) * prime[i];
                bad < tr; bad += prime[i]) {

                block[bad - tl] = false;
            }
        }
        if (bId == 0) {
            block[0] = block[1] = false;
        }
        for(int i = tl; i < tr; ++i) {
            if (block[i]) {
                add(tl + i);
            }
        }
        if (tr >= n) break;
    }

    cout << result << endl;

    return 0;
}


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

#define fst first
#define snd second
#define mp make_pair
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define per(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()

template <typename T1, typename T2>
inline bool umin(T1& x, const T2& y){return x>y ? x=y,true : false;}

template <typename T1, typename T2>
inline bool umax(T1& x, const T2& y){return x<y ? x=y,true : false;}

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef pair<int,int> pii;

const int N = (int)2e4+5;
const int mod = (int)1e9+7;
const int INF = (int)1e9+17;
const ll LLINF = (ll)1e18+17;

int n;
uint result = 0;
uint A, B, C, D;

const uint BLOCK = (uint)1e4;
const uint SQRTMAX = (uint)2e4+1;

int prime[SQRTMAX];
bool block[BLOCK+8];
bool isprime[SQRTMAX];

int iPrime = 0;

inline uint f(uint p) {return A*p*p*p + B*p*p + C*p + D;}

inline void add(uint prime) {
    int power = 1;
    int64_t val = prime;
    while (val <= n) {
        ++power;
        val *= prime;
    }
    --power;
    val /= prime;
    int total = 0;
    while (power > 0) {
        result += (uint)(n / val - total) * power * f(prime);
        total += n / val - total;
        --power;
        val /= prime;
    }

}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    cin >> n >> A >> B >> C >> D;

    fill(isprime, isprime+SQRTMAX, true);
    isprime[0] = isprime[1] = false;
    for(int i = 2; i * i <= n; ++i) {
        if (!isprime[i]) continue;
        prime[iPrime++] = i;
        for(int j = i * i; j < SQRTMAX; j += i) {
            isprime[j] = false;
        }
    }
    for(int bId = 0; ; ++bId) {
        int tl = bId * BLOCK, tr = min<int>(n+1, tl + BLOCK);
        fill(block, block+BLOCK, true);
        for(int i = 0; i < iPrime; ++i) {
            for(int bad = max(2, (tl + prime[i] - 1) / prime[i]) * prime[i];
                bad < tr; bad += prime[i]) {

                block[bad - tl] = false;
            }
        }
        if (bId == 0) {
            block[0] = block[1] = false;
        }
        for(int i = tl; i < tr; ++i) {
            if (block[i - tl]) {
                add(i);
            }
        }
        if (tr >= n) break;
    }

    cout << result << endl;

    return 0;
}


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

#define fst first
#define snd second
#define mp make_pair
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define per(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()

template <typename T1, typename T2>
inline bool umin(T1& x, const T2& y){return x>y ? x=y,true : false;}

template <typename T1, typename T2>
inline bool umax(T1& x, const T2& y){return x<y ? x=y,true : false;}

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef pair<int,int> pii;

const int N = (int)2e4+5;
const int mod = (int)1e9+7;
const int INF = (int)1e9+17;
const ll LLINF = (ll)1e18+17;

int n;
uint result;
uint A, B, C, D;

const uint BLOCK = (uint)1e4;
const uint SQRTMAX = (uint)2e4+1;

int prime[SQRTMAX];
bool block[BLOCK];
bool isprime[SQRTMAX];

int iPrime = 0;

inline uint f(uint p) {return A*p*p*p + B*p*p + C*p + D;}

inline void add(uint prime) {
    int power = 1;
    int64_t val = prime;
    while (val <= n) {
        ++power;
        val *= prime;
    }
    --power;
    val /= prime;
    int total = 0;
    while (power > 0) {
        result += (uint)(n / val - total) * power * f(prime);
        total += n / val - total;
        --power;
        val /= prime;
    }

}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    cin >> n >> A >> B >> C >> D;

    fill(isprime, isprime+SQRTMAX, true);
    isprime[0] = isprime[1] = false;
    for(int i = 2; i * i <= n; ++i) {
        if (!isprime[i]) continue;
        prime[iPrime++] = i;
        for(int j = i * i; j <= n; j += i) {
            isprime[j] = false;
        }
    }

    for(int bId = 0; ; ++bId) {
        int tl = bId * BLOCK, tr = min<int>(n+1, tl + BLOCK);
        fill(block, block+BLOCK, true);
        for(int i = 0; i < iPrime; ++i) {
            for(int bad = max(2, (tl + prime[i] - 1) / prime[i]) * prime[i];
                bad < tr; bad += prime[i]) {

                block[bad - tl] = false;
            }
        }
        if (bId == 0) {
            block[0] = block[1] = false;
        }
        for(int i = tl; i < tr; ++i) {
            if (block[i]) {
                add(tl + i);
            }
        }
        if (tr >= n) break;
    }

    cout << result << endl;

    return 0;
}


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pi;

#define maxn 40000

bool num[40005] ;
unsigned int sz = 0 , p[maxn] ;

void sieve()
{
    for(unsigned int i=2 ; i*i<=maxn ; i++)
    {
        if(num[i]==0) for(unsigned int j=i+i ; j<=maxn ; j+=i) num[j] =  1 ;
    }
    for(unsigned int j=2 ; j<=maxn ; j++)
    {
        if( num[j]==0 ) p[++sz] = j ;
    }
    return ;
}

unsigned int A , B , C , D , ans = 0 , n ;

void f( unsigned int pr )
{
    if(pr<2) return ;
    unsigned int pw = 1 ,ret=0 ;
    ret += D ;
    pw*=pr ;
    ret += pw*C ;
    pw *= pr ;
    ret += B*pw ;
    pw*=pr ;
    ret += A*pw ;

    unsigned coEff = 0 ;
    unsigned m = n ;
    while( m!=0 )
    {
        m /= pr ;
        coEff += m ;
    }
  //  printf("%u %u\n",pr,coEff) ;
    ans += coEff*ret ;
}

int main()
{
    sieve() ;
  //  DBG ;

    unsigned int i , j , k , l , m ;

 //   for(j=1 ; j<=10  ;j++) printf("%u\n",p[j]) ;

    scanf("%u %u %u %u %u",&n,&A,&B,&C,&D) ;

    unsigned int mx = 5000000 ;

    bitset <5000000> b ;

    for(i=0 ; i<40 ; i++)
    {
        unsigned int stEra = i*mx , endEra = i*mx+mx-1 ;

        if( i*mx > n ) break ;
        for(j=0 ; j<mx ; j++) b[j] = 0 ;

        for(j=1 ; p[j]*p[j]<=n && j<=sz ; j++)
        {
            unsigned int st = (stEra+p[j]-1)/p[j] ;
            k = (st*p[j]) - stEra ;
            if(i==0) k = p[j]+p[j] ;
            for(  ; k<=endEra ; k+=p[j])
            {
                b[k] = 1 ;
            }
         }
         for(j=0 ; j<mx && stEra+j <=n ; j++)
         {
             if( b[j]==0 )
             {
                 f(stEra+j) ;
             }
         }
    }

    printf("%u\n",ans) ;

    return 0 ;
}


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pi;

#define maxn 40000

bool num[40005] ;
unsigned int sz = 0 , p[maxn] ;

void sieve()
{
    for(unsigned int i=2 ; i*i<=maxn ; i++)
    {
        if(num[i]==0) for(unsigned int j=i+i ; j<=maxn ; j+=i) num[j] =  1 ;
    }
    for(unsigned int j=2 ; j<=maxn ; j++)
    {
        if( num[j]==0 ) p[++sz] = j ;
    }
    return ;
}

unsigned int A , B , C , D , ans = 0 , n ;

void f( unsigned int pr )
{
    if(pr<2) return ;
    unsigned int pw = 1 ,ret=0 ;
    ret += D ;
    pw*=pr ;
    ret += pw*C ;
    pw *= pr ;
    ret += B*pw ;
    pw*=pr ;
    ret += A*pw ;

    unsigned coEff = 0 ;
    unsigned m = n ;
    while( m!=0 )
    {
        m /= pr ;
        coEff += m ;
    }
  //  printf("%u %u\n",pr,coEff) ;
    ans += coEff*ret ;
}

int main()
{
    sieve() ;
  //  DBG ;

    unsigned int i , j , k , l , m ;

 //   for(j=1 ; j<=10  ;j++) printf("%u\n",p[j]) ;

    scanf("%u %u %u %u %u",&n,&A,&B,&C,&D) ;

    unsigned int mx = 5000000 ;

    bitset <5000000> b ;

    for(i=0 ; i<40 ; i++)
    {
        unsigned int stEra = i*mx , endEra = i*mx+mx-1 ;

        if( i*mx > n ) break ;
        for(j=0 ; j<mx ; j++) b[j] = 0 ;

        for(j=1 ; p[j]*p[j]<=n && j<=sz ; j++)
        {
            unsigned int st = (stEra+p[j]-1)/p[j] ;
            k = (st*p[j]) - stEra ;
            if(i==0) k = p[j]+p[j] ;
            for(  ; k<mx ; k+=p[j])
            {
                b[k] = 1 ;
            }
         }
         for(j=0 ; j<mx && stEra+j <=n ; j++)
         {
             if( b[j]==0 )
             {
                 f(stEra+j) ;
             }
         }
    }

    printf("%u\n",ans) ;

    return 0 ;
}


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pi;

#define maxn 40000

bool num[40005] ;
unsigned int sz = 0 , p[maxn] ;

void sieve()
{
    for(unsigned int i=2 ; i*i<=maxn ; i++)
    {
        if(num[i]==0) for(unsigned int j=i+i ; j<=maxn ; j+=i) num[j] =  1 ;
    }
    for(unsigned int j=2 ; j<=maxn ; j++)
    {
        if( num[j]==0 ) p[++sz] = j ;
    }
    return ;
}

unsigned int A , B , C , D , ans = 0 , n ;

void f( unsigned int pr )
{
    if(pr<2) return ;
    unsigned int pw = 1 ,ret=0 ;
    ret += D ;
    pw*=pr ;
    ret += pw*C ;
    pw *= pr ;
    ret += B*pw ;
    pw*=pr ;
    ret += A*pw ;

    unsigned coEff = 0 ;
    unsigned m = n ;
    while( m!=0 )
    {
        m /= pr ;
        coEff += m ;
    }
  //  printf("%u %u\n",pr,coEff) ;
    ans += coEff*ret ;
}

int main()
{
    sieve() ;
  //  DBG ;

    unsigned int i , j , k , l , m ;

 //   for(j=1 ; j<=10  ;j++) printf("%u\n",p[j]) ;

    scanf("%u %u %u %u %u",&n,&A,&B,&C,&D) ;

    unsigned int mx = 5000000 ;

    bitset <5000000> b ;

    for(i=0 ; i<40000 ; i++)
    {
        unsigned int stEra = i*mx , endEra = i*mx+mx-1 ;

        if( i*mx > n ) break ;
        for(j=0 ; j<mx ; j++) b[j] = 0 ;

        for(j=1 ; p[j]*p[j]<=n && j<=sz ; j++)
        {
            unsigned int st = (stEra+p[j]-1)/p[j] ;
            k = (st*p[j]) - stEra ;
            if(i==0) k = p[j]+p[j] ;
            for(  ; k<mx ; k+=p[j])
            {
                b[k] = 1 ;
            }
         }
         for(j=0 ; j<mx && stEra+j <=n ; j++)
         {
             if( b[j]==0 )
             {
                 f(stEra+j) ;
             }
         }
    }

    printf("%u\n",ans) ;

    return 0 ;
}


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pi;

#define maxn 40000

bool num[40005] ;
unsigned int sz = 0 , p[maxn] ;

void sieve()
{
    for(unsigned int i=2 ; i*i<=maxn ; i++)
    {
        if(num[i]==0) for(unsigned int j=i+i ; j<=maxn ; j+=i) num[j] =  1 ;
    }
    for(unsigned int j=2 ; j<=maxn ; j++)
    {
        if( num[j]==0 ) p[++sz] = j ;
    }
    return ;
}

unsigned int A , B , C , D , ans = 0 , n ;

void f( unsigned int pr )
{
    if(pr<2) return ;
    unsigned int pw = 1 ,ret=0 ;
    ret += D ;
    pw*=pr ;
    ret += pw*C ;
    pw *= pr ;
    ret += B*pw ;
    pw*=pr ;
    ret += A*pw ;

    unsigned coEff = 0 ;
    unsigned m = n ;
    while( m!=0 )
    {
        m /= pr ;
        coEff += m ;
    }
  //  printf("%u %u\n",pr,coEff) ;
    ans += coEff*ret ;
}

int main()
{
    sieve() ;
  //  DBG ;

    unsigned int i , j , k , l , m ;

 //   for(j=1 ; j<=10  ;j++) printf("%u\n",p[j]) ;

    scanf("%u %u %u %u %u",&n,&A,&B,&C,&D) ;

    unsigned int mx = 10000000 ;

    for(i=0 ; i<40 ; i++)
    {
        unsigned int stEra = i*mx , endEra = i*mx+mx-1 ;

        if( i*mx > n ) break ;

        bitset <10000000> b ;

        for(j=0 ; j<mx ; j++) b[j] = 0 ;

        for(j=1 ; p[j]*p[j]<=n && j<=sz ; j++)
        {
            unsigned int st = (stEra+p[j]-1)/p[j] ;
            k = (st*p[j]) - stEra ;
            if(i==0) k = p[j]+p[j] ;
            for(  ; k<=endEra ; k+=p[j])
            {
                b[k] = 1 ;
            }
         }
         for(j=0 ; j<mx && stEra+j <=n ; j++)
         {
             if( b[j]==0 )
             {
                 f(stEra+j) ;
             }
         }
    }

    printf("%u\n",ans) ;

    return 0 ;
}


#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn=1e5+100;
uint n, A, B, C, D, ans;
uint get(uint x)
{
    return ((A*x+B)*x+C)*x+D;
}
uint cnt(uint x)
{
    uint xx=x, ret=0;
    while(x<=n)
    {
        ret+=n/x;
        x*=xx;
    }
    return ret;
}
void f(uint x)
{
    ans+=cnt(x)*get(x);
}
bitset<50000100>five, one;
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin>>n>>A>>B>>C>>D;
    if(n<=2)f(2);
    if(n<=3)f(3);
    for(uint i=0; i<50000100; i++)five[i]=one[i]=true;
    for(uint i=5; i<=n; i++)
    {
        if(i%6==1 && one[i/6])
        {
            f(i);
            for(uint j=i*i; j<=n; j+=i)
                {
                    if(j%6==1)one[j/6]=false;
                    if(j%6==5)five[j/6]=false;
                }
        }
        if(i%6==5 && five[i/6])
        {
            f(i);
            for(uint j=i*i; j<=n; j+=i)
                {
                    if(j%6==1)one[j/6]=false;
                    if(j%6==5)five[j/6]=false;
                }
        }
    }
    cout<<ans<<"\n";
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn=1e5+100;
uint n, A, B, C, D, ans;
uint get(uint x)
{
    return ((A*x+B)*x+C)*x+D;
}
uint cnt(uint x)
{
    uint xx=x, ret=0;
    while(true)
    {
        ret+=n/x;
        if((ll)x*(ll)xx>(ll)n)break;
        x*=xx;
    }
    return ret;
}
void f(uint x)
{
    ans+=cnt(x)*get(x);
}
bitset<50000100>five, one;
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin>>n>>A>>B>>C>>D;
    if(n>=2)f(2);
    if(n>=3)f(3);
    for(uint i=0; i<50000100; i++)five[i]=one[i]=true;
    for(uint i=5; i<=n; i++)
    {
        if(i%6==1 && one[i/6])
        {
            f(i);
            for(uint j=i+i; j<=n; j+=i)
                {
                    if(j%6==1)one[j/6]=false;
                    if(j%6==5)five[j/6]=false;
                }
        }
        if(i%6==5 && five[i/6])
        {
            f(i);
            for(uint j=i+i; j<=n; j+=i)
                {
                    if(j%6==1)one[j/6]=false;
                    if(j%6==5)five[j/6]=false;
                }
        }
    }
    cout<<ans<<"\n";
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn=1e5+100;
uint n, A, B, C, D, ans;
uint get(uint x)
{
    return ((A*x+B)*x+C)*x+D;
}
uint cnt(uint x)
{
    uint xx=x, ret=0;
    while(x<=n)
    {
        ret+=n/x;
        x*=xx;
    }
    return ret;
}
void f(uint x)
{
    ans+=cnt(x)*get(x);
}
bitset<50000100>five, one;
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin>>n>>A>>B>>C>>D;
    if(n>=2)f(2);
    if(n>=3)f(3);
    for(uint i=0; i<50000100; i++)five[i]=one[i]=true;
    for(uint i=5; i<=n; i++)
    {
        if(i%6==1 && one[i/6])
        {
            f(i);
            for(uint j=i*i; j<=n; j+=i)
                {
                    if(j%6==1)one[j/6]=false;
                    if(j%6==5)five[j/6]=false;
                }
        }
        if(i%6==5 && five[i/6])
        {
            f(i);
            for(uint j=i*i; j<=n; j+=i)
                {
                    if(j%6==1)one[j/6]=false;
                    if(j%6==5)five[j/6]=false;
                }
        }
    }
    cout<<ans<<"\n";
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn=1e5+100;
uint n, A, B, C, D, ans;
uint get(uint x)
{
    return ((A*x+B)*x+C)*x+D;
}
uint cnt(uint x)
{
    uint xx=x, ret=0;
    while(x<=n)
    {
        ret+=n/x;
        x*=xx;
    }
    return ret;
}
void f(uint x)
{
    ans+=cnt(x)*get(x);
}
bitset<50000100>five, one;
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin>>n>>A>>B>>C>>D;
    f(2);
    f(3);
    for(uint i=0; i<50000100; i++)five[i]=one[i]=true;
    for(uint i=5; i<=n; i++)
    {
        if(i%6==1 && one[i/6])
        {
            f(i);
            for(uint j=i*i; j<=n; j+=i)
                one[j/6]=false;
        }
        if(i%6==5 && five[i/6])
        {
            f(i);
            for(uint j=i*i; j<=n; j+=i)
                five[j/6]=false;
        }
    }
    cout<<ans<<"\n";
    return 0;
}


#include <bits/stdc++.h>
#ifdef LOCAL
#define deb(...) fprintf(stderr,__VA_ARGS__)
#else
#define deb(...) 0
#endif
#define fore(x,a,b) for(int x=a, qwerty=b; x<qwerty; x++)
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())
#define pb push_back
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fst first
#define snd second
#define mset(a,v) memset((a),(v),sizeof(a))
using namespace std;

const uint N=3e8+5;
uint n;

int gcd(int a, int b){
    while(b){
        int c=a%b;
        b=c;a=b;
    }
    return a;
}
int mulmod(int a, int b, int m) {
    return (1LL*a)*(1LL*b)%(m);
}
int expmod(int b, int e, int m){
    int r=1;
    while(e)if(e&1)r=((1LL*r)*b)%m, e^=1; else b=((1LL*b)*b)%m,e>>=1;
    return r;
}
bool is_prime_prob(int n, int a){
	if(n==a)return true;
	int s=0,d=n-1;
	while(d%2==0)s++,d/=2;
	int x=expmod(a,d,n);
	if((x==1)||(x+1==n))return true;
	fore(_,0,s-1){
		x=mulmod(x,x,n);
		if(x==1)return false;
		if(x+1==n)return true;
	}
	return false;
}

int ar[]={2,3,5,7};
bool rabin(int n){
	fore(i,0,3)if(!is_prime_prob(n,ar[i]))return false;
	return true;
}

int main(){FIN;
    uint ans = 0, cnt, f, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    for(uint i=2; i<=n; i++)if(rabin(i)){
        uint tmp=n;
        cnt = 0;
        while(tmp)cnt+=tmp/i, tmp/=i;
        f=a*i*i*i+b*i*i+c*i+d;
        ans += f*cnt;
    }
    cout << ans << "\n";
}


#include <bits/stdc++.h>

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _CRT_SECURE_NO_WARNINGS

#ifdef LOCAL
#define deb(...) fprintf(stderr,__VA_ARGS__)
#else
#define deb(...) 0
#endif
#define fore(x,a,b) for(int x=a, qwerty=b; x<qwerty; x++)
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())
#define pb push_back
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fst first
#define snd second
#define mset(a,v) memset((a),(v),sizeof(a))
using namespace std;

const unsigned int N=3e8+5;
unsigned int n;

inline int expmod(int b, int e, int m){
    int r=1;
    while(e)if(e&1)r=((1LL*r)*b)%m, e^=1; else b=((1LL*b)*b)%m,e>>=1;
    return r;
}
bool is_prime_prob(int n, int a){
	if(n==a)return true;
	int s=0,d=n-1;
	while(d%2==0)s++,d/=2;
	int x=expmod(a,d,n);
	if((x==1)||(x+1==n))return true;
	fore(_,0,s-1){
		x=(1LL*x)*x%n;
		if(x==1)return false;
		if(x+1==n)return true;
	}
	return false;
}

int ar[]={2,3,5};
inline bool rabin(int n){
	fore(i,0,3)if(!is_prime_prob(n,ar[i]))return false;
	return true;
}

int main(){FIN;
    unsigned int ans = 0, cnt, f, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    unsigned int tmp=n;
        cnt = 0;
        while(tmp)cnt+=(tmp/=2);
        f=((a*2+b)*2+c)*2+d;
        ans += f*cnt;
    for(unsigned int i=3; i<=n; i+=2)if(rabin(i)){
        unsigned int tmp=n;
        cnt = 0;
        while(tmp)cnt+=(tmp/=i);
        f=((a*i+b)*i+c)*i+d;
        ans += f*cnt;
    }
    cout << ans << "\n";
}


#include <bits/stdc++.h>
#ifdef LOCAL
#define deb(...) fprintf(stderr,__VA_ARGS__)
#else
#define deb(...) 0
#endif
#define fore(x,a,b) for(int x=a, qwerty=b; x<qwerty; x++)
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())
#define pb push_back
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fst first
#define snd second
#define mset(a,v) memset((a),(v),sizeof(a))
using namespace std;

const int N=3e8+5;
const int SQ=17325;
unsigned int n;
vector<int> ps;
bitset<SQ> bs;
#define uint unsigned int
uint ans = 0, cnt, f, a, b, c, d;
void upd(uint i){
    uint tmp=n;
    cnt = 0;
    while(tmp)cnt+=(tmp/=i);
    f=((a*i+b)*i+c)*i+d;
    ans += f*cnt;
}

int main(){FIN;
    cin >> n >> a >> b >> c >> d;
    for(int i=2; i<SQ; i++)if(!bs[i]){
        ps.pb(i);
        for(int j=i; j<SQ; j+=i)bs[j]=1;
        upd(i);
    }
    uint buc=1;
    while(1){
        bs.reset();
        for(int i:ps){
            for(uint j=((buc*SQ+i-1)/i)*i; j<(buc+1)*SQ; j+=i)
                bs[j-buc*SQ]=1;
        }
        for(uint i=buc*SQ; i<(buc+1)*SQ; i++){
            if(i>n)break;
            if(!bs[i-buc*SQ])upd(i);
        }
        buc++;
        if(buc*SQ>n)break;
    }
    cout << ans << "\n";
}


#include <bits/stdc++.h>
#ifdef LOCAL
#define deb(...) fprintf(stderr,__VA_ARGS__)
#else
#define deb(...) 0
#endif
#define fore(x,a,b) for(int x=a, qwerty=b; x<qwerty; x++)
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())
#define pb push_back
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fst first
#define snd second
#define mset(a,v) memset((a),(v),sizeof(a))
using namespace std;
typedef long long ll;

const ll MOD=1LL<<32;
const int N=3e8+5;
bitset<N> bs;
int n;

ll add(ll a, ll b){a+=b; if(a>=MOD)a-=MOD; return a;}
ll mult(ll a, ll b){return (a*b)%MOD;}

int main(){FIN;
    ll ans = 0, cnt, f, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    for(ll i=2; i<=n; i++)if(!bs[i]){
        int tmp=n;
        for(int y=i; y<=n; y+=i)bs[y]=1;
        cnt = 0;
        while(tmp)cnt+=tmp/i, tmp/=i;
        cnt %= MOD;
        f = add(mult(mult(a,i),mult(i,i)), mult(b,mult(i,i)));
        f = add(f, mult(c,i));
        f = add(f, d);
        f = mult(f, cnt);
        ans = add(ans,f);
    }
    cout << ans << "\n";
}


#include <bits/stdc++.h>
#ifdef LOCAL
#define deb(...) fprintf(stderr,__VA_ARGS__)
#else
#define deb(...) 0
#endif
#define fore(x,a,b) for(int x=a, qwerty=b; x<qwerty; x++)
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())
#define pb push_back
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fst first
#define snd second
#define mset(a,v) memset((a),(v),sizeof(a))
using namespace std;

const int N=3e8+5;
const int SQ=17325;
unsigned int n;
vector<int> ps;
bitset<SQ> bs;
#define uint unsigned int
uint ans = 0, cnt, f, a, b, c, d;
void upd(uint i){
    uint tmp=n;
    cnt = 0;
    while(tmp)cnt+=(tmp/=i);
    f=((a*i+b)*i+c)*i+d;
    ans += f*cnt;
}

int main(){FIN;
    cin >> n >> a >> b >> c >> d;
    for(int i=2; i<SQ; i++)if(!bs[i]){
        ps.pb(i);
        for(int j=i; j<SQ; j+=i)bs[j]=1;
        upd(i);
    }
    uint buc=1;
    while(1){
        bs.reset();
        for(int i:ps){
            for(uint j=((buc*SQ+i-1)/i)*i; j<(buc+1)*SQ; j+=i)
                bs[j-buc*SQ]=1;
        }
        for(uint i=buc*SQ; i<(buc+1)*SQ; i++){
            if(i>n)break;
            cout << "  " << i << "\n";
            if(!bs[i-buc*SQ])upd(i);
        }
        buc++;
        if(buc*SQ>n)break;
    }
    cout << ans << "\n";
}


#include <bits/stdc++.h>
#ifdef LOCAL
#define deb(...) fprintf(stderr,__VA_ARGS__)
#else
#define deb(...) 0
#endif
#define fore(x,a,b) for(int x=a, qwerty=b; x<qwerty; x++)
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())
#define pb push_back
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fst first
#define snd second
#define mset(a,v) memset((a),(v),sizeof(a))
using namespace std;

const unsigned int N=3e8+5;
unsigned int n;

int gcd(int a, int b){
    while(b){
        int c=a%b;
        b=c;a=b;
    }
    return a;
}
int mulmod(int a, int b, int m) {
    return (1LL*a)*(1LL*b)%(m);
}
int expmod(int b, int e, int m){
    int r=1;
    while(e)if(e&1)r=((1LL*r)*b)%m, e^=1; else b=((1LL*b)*b)%m,e>>=1;
    return r;
}
bool is_prime_prob(int n, int a){
	if(n==a)return true;
	int s=0,d=n-1;
	while(d%2==0)s++,d/=2;
	int x=expmod(a,d,n);
	if((x==1)||(x+1==n))return true;
	fore(_,0,s-1){
		x=mulmod(x,x,n);
		if(x==1)return false;
		if(x+1==n)return true;
	}
	return false;
}

int ar[]={2,3,5,7};
bool rabin(int n){
	fore(i,0,3)if(!is_prime_prob(n,ar[i]))return false;
	return true;
}

int main(){FIN;
    unsigned int ans = 0, cnt, f, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    for(unsigned int i=2; i<=n; i++)if(rabin(i)){
        unsigned int tmp=n;
        cnt = 0;
        while(tmp)cnt+=tmp/i, tmp/=i;
        f=a*i*i*i+b*i*i+c*i+d;
        ans += f*cnt;
    }
    cout << ans << "\n";
}


#include <bits/stdc++.h>

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _CRT_SECURE_NO_WARNINGS

#ifdef LOCAL
#define deb(...) fprintf(stderr,__VA_ARGS__)
#else
#define deb(...) 0
#endif
#define fore(x,a,b) for(int x=a, qwerty=b; x<qwerty; x++)
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())
#define pb push_back
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fst first
#define snd second
#define mset(a,v) memset((a),(v),sizeof(a))
using namespace std;

const unsigned int N=3e8+5;
unsigned int n;

inline int expmod(int b, int e, int m){
    int r=1;
    while(e)if(e&1)r=((1LL*r)*b)%m, e^=1; else b=((1LL*b)*b)%m,e>>=1;
    return r;
}
bool is_prime_prob(int n, int a){
	if(n==a)return true;
	int s=0,d=n-1;
	while(d%2==0)s++,d/=2;
	int x=expmod(a,d,n);
	if((x==1)||(x+1==n))return true;
	fore(_,0,s-1){
		x=(1LL*x)*x%n;
		if(x==1)return false;
		if(x+1==n)return true;
	}
	return false;
}

int ar[]={2,3,5,7};
inline bool rabin(int n){
	fore(i,0,3)if(!is_prime_prob(n,ar[i]))return false;
	return true;
}

int main(){FIN;
    unsigned int ans = 0, cnt, f, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    for(unsigned int i=2; i<=n; i++)if(rabin(i)){
        unsigned int tmp=n;
        cnt = 0;
        while(tmp)cnt+=tmp/i, tmp/=i;
        f=a*i*i*i+b*i*i+c*i+d;
        ans += f*cnt;
    }
    cout << ans << "\n";
}


#include <bits/stdc++.h>
using namespace std;
unsigned int n, a, b, c, d, rez;
bool viz[30005];
vector<unsigned int> prime;
unsigned int fct(unsigned int x)
{
   return d+x*(c+ x*(b+x*a));
}
void adauga(unsigned int x)
{
    unsigned int contr=0; long long val=x;
    while(n/val>0)
    {
        contr+=n/val; val*=(x);
    }
    rez+=fct(x)*contr;
}
void calc(unsigned int val)
{
    unsigned int i, j;
    prime.clear();
    for(i=2; i<=val; i++)
        if(!viz[i])
    {
        prime.push_back(i);
        adauga(i);
        for(j=i*2; j<=val; j+=i)
            viz[j]=1;
    }
}
void ext_eratos(unsigned int n)
{
    unsigned int sqr=sqrt(n), l, r, m;
    calc(sqr);
    l=sqr+1;
    while(l<=n)
    {
        r=min(n, l+sqr-1);
        for(unsigned int i=0; i<sqr; i++)
            viz[i]=0;
        for(auto it=prime.begin(); it!=prime.end(); ++it)
        {
            m=(l/(*it))*(*it);
            while(m< l) m+=*it;
            while(m<=r) {viz[m-l]=1; m+=*it;}
        }
        for(unsigned int i=0; i<=r-l; i++)
            if(!viz[i]) adauga(i+l);
        l+=sqr;
    }

}
int main()
{
    cin>>n>>a>>b>>c>>d;
    ext_eratos(n);
    cout<<rez;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
long long n, a, b, c, d, rez, mod;
bool viz[30005];
vector<int> prime;
long long fct(long long x)
{
    long long val=d;
    val+=(((a*x)%mod*x)%mod*x)%mod; val%=mod;
    val+=((b*x)%mod*x)%mod; val%=mod;
    val+=(c*x)%mod; val%=mod;
    return val;
}
void calc(int val)
{
    int i, j;
    prime.clear();
    for(i=2; i<=val; i++)
        if(!viz[i])
    {
        prime.push_back(i);
        for(j=i*2; j<=val; j+=i)
            viz[j]=1;
    }
}
void ext_eratos(int n)
{
    int sqr=sqrt(n), l, r, m;
    calc(sqr);
    l=sqr+1;
    while(l<=n)
    {
        r=min(n, l+sqr-1);
        memset(viz, 0, sizeof(viz));
        for(auto it=prime.begin(); it!=prime.end(); ++it)
        {
            m=(l/(*it))*(*it);
            while(m< l) m+=*it;
            while(m<=r) {viz[m-l]=1; m+=*it;}
        }
        for(int i=0; i<=r-l; i++)
            if(!viz[i]) prime.push_back(i+l);
        l+=sqr;
    }

}
 int main()
{
    long long contr, val;
    mod=1; int i=1;
    while(i<=32) {mod*=2; i++;}

    cin>>n>>a>>b>>c>>d;
    ext_eratos(n);
    /*for(auto it=prime.begin(); it!=prime.end(); ++it)
        cout<<*it<<"\n";*/
    for(auto it=prime.begin(); it!=prime.end(); ++it)
    {
        contr=0; val=(*it);
        while(n/val>0)
        {
            contr+=n/val; val*=(*it);
        }
        rez+=(fct(*it)*contr)%mod; rez%=mod;
    }
    cout<<rez;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
unsigned int n, a, b, c, d, rez;
bool viz[30005];
vector<unsigned int> prime;
unsigned int fct(unsigned int x)
{
   return d+x*(c+ x*(b+x*a));
}
void adauga(unsigned int x)
{
    unsigned int contr=0; unsigned int val=x;
    while(n/val>0)
    {
        contr+=n/val; val*=(x);
    }
    rez+=fct(x)*contr;
}
void calc(unsigned int val)
{
    unsigned int i, j;
    prime.clear();
    for(i=2; i<=val; i++)
        if(!viz[i])
    {
        prime.push_back(i);
        adauga(i);
        for(j=i*2; j<=val; j+=i)
            viz[j]=1;
    }
}
void ext_eratos(unsigned int n)
{
    unsigned int sqr=sqrt(n), l, r, m;
    calc(sqr);
    l=sqr+1;
    while(l<=n)
    {
        r=min(n, l+sqr-1);
        for(unsigned int i=0; i<sqr; i++)
            viz[i]=0;
        for(auto it=prime.begin(); it!=prime.end(); ++it)
        {
            m=(l/(*it))*(*it);
            while(m< l) m+=*it;
            while(m<=r) {viz[m-l]=1; m+=*it;}
        }
        for(unsigned int i=0; i<=r-l; i++)
            if(!viz[i]) adauga(i+l);
        l+=sqr;
    }

}
int main()
{
    cin>>n>>a>>b>>c>>d;
    ext_eratos(n);
    cout<<rez;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n, a, b, c, d, rez;
bool viz[30005];
vector<int> prime;
int fct(int x)
{
   return d+x*(c+ x*(b+x*a));
}
void calc(int val)
{
    int i, j;
    prime.clear();
    for(i=2; i<=val; i++)
        if(!viz[i])
    {
        prime.push_back(i);
        for(j=i*2; j<=val; j+=i)
            viz[j]=1;
    }
}
void ext_eratos(int n)
{
    int sqr=sqrt(n), l, r, m;
    calc(sqr);
    l=sqr+1;
    while(l<=n)
    {
        r=min(n, l+sqr-1);
        for(int i=0; i<sqr; i++)
            viz[i]=0;
        for(auto it=prime.begin(); it!=prime.end(); ++it)
        {
            m=(l/(*it))*(*it);
            while(m< l) m+=*it;
            while(m<=r) {viz[m-l]=1; m+=*it;}
        }
        for(int i=0; i<=r-l; i++)
            if(!viz[i]) prime.push_back(i+l);
        l+=sqr;
    }

}
 int main()
{
    int contr, val;
    cin>>n>>a>>b>>c>>d;
    ext_eratos(n);
    for(auto it=prime.begin(); it!=prime.end(); ++it)
    {
        contr=0; val=(*it);
        while(n/val>0)
        {
            contr+=n/val; val*=(*it);
        }
        rez+=fct(*it)*contr;
    }
    cout<<rez;
    return 0;
}


//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("avx")
#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define re return
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqrt(x) sqrt(abs(x))
#define y0 y3487465
#define y1 y8687969
#define j0 j5743892
#define j1 j542893

typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<vi> vvi;

template<class T> T abs(T x) { re x > 0 ? x : -x; }
template<class T> T gcd(T a, T b) { re a ? gcd (b % a, a) : b; }
template<class T> T sqr(T a) { re a * a; }
template<class T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }

const double pi = acos(-1.0);

#define filename ""

int n;
int m;

const int N = 3e8 / 3 + 10;

bitset <N> a;

bool check (int i)
{
    re i % 2 > 0 && i % 3 > 0;
}

int get_ind(int i)
{
    re i - (i / 2 + i / 3 - i / 6);
}

unsigned int ans = 0, A, B, C, D;

void upd_ans(unsigned int x)
{
    ll pw = x;
    unsigned int res = 0;
    for (; (ll)pw <= n; pw *= x) {
        res += (unsigned int)n / pw;
    }
    ans += res * (A * x * x * x + B * x * x + C * x + D);
}

int main () {
//  freopen (filename".in", "r", stdin);
//  freopen (filename".out", "w", stdout);
    cin >> n >> A >> B >> C >> D;
    for (int i = 3; i * i < n; i ++) {
        if (check(i)) {
            for (int j = i * i; j < n; j += i) if (check(j)) a[get_ind(j)] = 1;
        }
    }
    upd_ans(2);
    upd_ans(3);

    for (int i = 3; i < n; i ++) {
        if (check (i)) {
            if (a[get_ind(i)] == 0) {
                upd_ans(i);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("avx")
#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define re return
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqrt(x) sqrt(abs(x))
#define y0 y3487465
#define y1 y8687969
#define j0 j5743892
#define j1 j542893

typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<vi> vvi;

template<class T> T abs(T x) { re x > 0 ? x : -x; }
template<class T> T gcd(T a, T b) { re a ? gcd (b % a, a) : b; }
template<class T> T sqr(T a) { re a * a; }
template<class T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }

const double pi = acos(-1.0);

#define filename ""

int n;
int m;

const int N = 3e8 / 3 + 1;

bitset <N> a;

bool check (int i)
{
    re i % 2 > 0 && i % 3 > 0;
}

int get_ind(int i)
{
    re i - (i / 2 + i / 3 - i / 6);
}

unsigned int ans = 0, A, B, C, D;

void upd_ans(unsigned int x)
{
    ll pw = x;
    unsigned int res = 0;
    for (; (ll)pw <= n; pw *= x) {
        res += (unsigned int)n / pw;
    }
    ans += res * (A * x * x * x + B * x * x + C * x + D);
}

int main () {
//  freopen (filename".in", "r", stdin);
//  freopen (filename".out", "w", stdout);
    cin >> n >> A >> B >> C >> D;
    for (int i = 3; i < n; i ++) {
        if (check(i)) {
            for (int j = i * i; j < n; j += i) if (check(j)) a[get_ind(j)] = 1;
        }
    }
    upd_ans(2);
    upd_ans(3);

    for (int i = 3; i < n; i ++) {
        if (check (i)) {
            if (a[get_ind(i)] == 0) {
                upd_ans(i);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("avx")
#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define re return
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqrt(x) sqrt(abs(x))
#define y0 y3487465
#define y1 y8687969
#define j0 j5743892
#define j1 j542893

typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<vi> vvi;

template<class T> T abs(T x) { re x > 0 ? x : -x; }
template<class T> T gcd(T a, T b) { re a ? gcd (b % a, a) : b; }
template<class T> T sqr(T a) { re a * a; }
template<class T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }

const double pi = acos(-1.0);

#define filename ""

int n;
int m;

const int N = 3e8 / 3 + 100;

bitset <N> a;

bool check (int i)
{
    re i % 2 > 0 && i % 3 > 0;
}

int get_ind(int i)
{
    re i - (i / 2 + i / 3 - i / 6);
}

unsigned int ans = 0, A, B, C, D;

void upd_ans(unsigned int x)
{
    ll pw = x;
    unsigned int res = 0;
    for (; (ll)pw <= n; pw *= x) {
        res += (unsigned int)n / pw;
    }
    ans += res * (A * x * x * x + B * x * x + C * x + D);
}

int main () {
//  freopen (filename".in", "r", stdin);
//  freopen (filename".out", "w", stdout);
    cin >> n >> A >> B >> C >> D;
    for (int i = 3; i < n; i ++) {
        if (check(i)) {
            for (int j = i * i; j < n; j += i) if (check(j)) a[get_ind(j)] = 1;
        }
    }
    upd_ans(2);
    upd_ans(3);

    for (int i = 3; i < n; i ++) {
        if (check (i)) {
            if (a[get_ind(i)] == 0) {
                upd_ans(i);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("avx")
#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define re return
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqrt(x) sqrt(abs(x))
#define y0 y3487465
#define y1 y8687969
#define j0 j5743892
#define j1 j542893

typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<vi> vvi;

template<class T> T abs(T x) { re x > 0 ? x : -x; }
template<class T> T gcd(T a, T b) { re a ? gcd (b % a, a) : b; }
template<class T> T sqr(T a) { re a * a; }
template<class T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }

const double pi = acos(-1.0);

#define filename ""

int n;
int m;

const int N = 3e8 / 3 + 10;

bitset <N> a;

bool check (int i)
{
    re i % 2 > 0 && i % 3 > 0;
}

int get_ind(int i)
{
    re i - (i / 2 + i / 3 - i / 6);
}

unsigned int ans = 0, A, B, C, D;

void upd_ans(unsigned int x)
{
    ll pw = x;
    unsigned int res = 0;
    for (; (ll)pw <= n; pw *= x) {
        res += (unsigned int)n / pw;
    }
    ans += res * (A * x * x * x + B * x * x + C * x + D);
}

int main () {
//  freopen (filename".in", "r", stdin);
//  freopen (filename".out", "w", stdout);
    cin >> n >> A >> B >> C >> D;
    for (int i = 3; i * i <= n; i ++) {
        if (check(i)) {
            for (int j = i * i; j <= n; j += i) if (check(j)) a[get_ind(j)] = 1;
        }
    }
    upd_ans(2);
    upd_ans(3);

    for (int i = 3; i <= n; i ++) {
        if (check (i)) {
            if (a[get_ind(i)] == 0) {
                upd_ans(i);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("avx")
#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define re return
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqrt(x) sqrt(abs(x))
#define y0 y3487465
#define y1 y8687969
#define j0 j5743892
#define j1 j542893

typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<vi> vvi;

template<class T> T abs(T x) { re x > 0 ? x : -x; }
template<class T> T gcd(T a, T b) { re a ? gcd (b % a, a) : b; }
template<class T> T sqr(T a) { re a * a; }
template<class T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }

const double pi = acos(-1.0);

#define filename ""

int n;
int m;

const int N = 3e8 / 4 + 10;

bitset <N> a;

bool check (int i)
{
    re i % 2 > 0 && i % 3 > 0;
}

int get_ind(int i)
{
    re i - (i / 2 + i / 3 - i / 6);
}

unsigned int ans = 0, A, B, C, D;

void upd_ans(unsigned int x)
{
    ll pw = x;
    unsigned int res = 0;
    for (; (ll)pw <= n; pw *= x) {
        res += (unsigned int)n / pw;
    }
    ans += res * (A * x * x * x + B * x * x + C * x + D);
}

int main () {
//  freopen (filename".in", "r", stdin);
//  freopen (filename".out", "w", stdout);
    cin >> n >> A >> B >> C >> D;
    for (int i = 3; i < n; i ++) {
        if (check(i)) {
            for (int j = i * i; j < n; j += i) if (check(j)) a[get_ind(j)] = 1;
        }
    }
    upd_ans(2);
    upd_ans(3);

    for (int i = 3; i < n; i ++) {
        if (check (i)) {
            if (a[get_ind(i)] == 0) {
                upd_ans(i);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("avx")
#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define re return
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqrt(x) sqrt(abs(x))
#define y0 y3487465
#define y1 y8687969
#define j0 j5743892
#define j1 j542893

typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<vi> vvi;

template<class T> T abs(T x) { re x > 0 ? x : -x; }
template<class T> T gcd(T a, T b) { re a ? gcd (b % a, a) : b; }
template<class T> T sqr(T a) { re a * a; }
template<class T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }

const double pi = acos(-1.0);

#define filename ""

int n;
int m;

const int N = 3e8 / 4 + 10;

bitset <N> a;

bool check (int i)
{
    re i % 2 > 0 && i % 3 > 0;
}

int get_ind(int i)
{
    re i - (i / 2 + i / 3 - i / 6);
}

unsigned int ans = 0, A, B, C, D;

void upd_ans(unsigned int x)
{
    ll pw = x;
    unsigned int res = 0;
    for (; (ll)pw <= n; pw *= x) {
        res += (unsigned int)n / pw;
    }
    cout << x << " " << res << endl;
    ans += res * (A * x * x * x + B * x * x + C * x + D);
}

int main () {
//  freopen (filename".in", "r", stdin);
//  freopen (filename".out", "w", stdout);
    cin >> n >> A >> B >> C >> D;
    for (int i = 3; i < n; i ++) {
        if (check(i)) {
            for (int j = i * i; j < n; j += i) if (check(j)) a[get_ind(j)] = 1;
        }
    }
    upd_ans(2);
    upd_ans(3);

    for (int i = 3; i < n; i ++) {
        if (check (i)) {
            if (a[get_ind(i)] == 0) {
                upd_ans(i);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll unsigned int
#define MAX 3e8
const int l = 17400;
const int sz = 10000000;
ll n, A, B, C, D;
bitset<sz+5> bits;
bool prime[l];
vector<ll> lst, plst;

ll calc(long long p)
{
    ll cnt = 0;
    long long mul = p;
    while(mul <= MAX){
        cnt += n/mul;
        mul = mul*p;
    }
    ll val = A*p*p*p + B*p*p + C*p + D;
    ll ret = val*cnt;
    return ret;
}

int main()
{
    cin >> n >> A >> B >> C >> D;
    prime[1] = false;
    memset(prime, true, sizeof prime);
    for(ll i=2; i<l; i++){
        if(prime[i]){
            for(ll j=2*i; j<l; j+=i) prime[j] = false;
        }
    }
    for(ll i=2; i<l; i++){
        if(prime[i]){
            lst.push_back(i);
            plst.push_back(i);
        }
    }
    ll nows = 1;
    ll ans = 0;
    while(nows <= MAX){
        bits.reset();
        if(nows == 1) bits[1] = 1;
        for(ll i=0; i<plst.size(); i++){
            while(lst[i]+plst[i]<=nows+sz-1){
                bits[lst[i]+plst[i]-nows+1] = 1;
                lst[i] += plst[i];
            }
        }
        for(ll i=1; i<=sz; i++){
            if(bits[i] == 1) continue;
            ans += calc(i+nows-1);
        }
        nows+=sz;
    }
    cout << ans;
}


#include <bits/stdc++.h>

using namespace std;

#define ll unsigned int
#define MAX 3e8
const int l = 17400;
const int sz = 10000000;
ll n, A, B, C, D;
bitset<sz+5> bits;
bool prime[l];
vector<int> lst, plst;

ll calc(ll p)
{
    ll cnt = 0;
    ll mul = p;
    while(mul <= MAX){
        cnt += n/mul;
        mul = mul*p;
    }
    ll val = A*p*p*p + B*p*p + C*p + D;
    ll ret = val*cnt;
    return ret;
}

int main()
{
    cin >> n >> A >> B >> C >> D;
    prime[1] = false;
    memset(prime, true, sizeof prime);
    for(int i=2; i<l; i++){
        if(prime[i]){
            for(int j=2*i; j<l; j+=i) prime[j] = false;
        }
    }
    for(int i=2; i<l; i++){
        if(prime[i]){
            lst.push_back(i);
            plst.push_back(i);
        }
    }
    int nows = 1;
    ll ans = 0;
    while(nows <= MAX){
        bits.reset();
        if(nows == 1) bits[1] = 1;
        for(int i=0; i<plst.size(); i++){
            while(lst[i]+plst[i]<=nows+sz-1){
                bits[lst[i]+plst[i]-nows+1] = 1;
                lst[i] += plst[i];
            }
        }
        for(int i=1; i<=sz; i++){
            if(bits[i] == 1) continue;
            ans += calc(i+nows-1);
        }
        nows+=sz;
    }
    cout << ans;
}


#include <bits/stdc++.h>

using namespace std;

#define ll unsigned int
#define MAX 3e8
const int l = 17400;
const int sz = 10000000;
ll n, A, B, C, D;
bitset<sz+5> bits;
bool prime[l];
vector<ll> lst, plst;

ll calc(ll p)
{
    ll cnt = 0;
    ll mul = p;
    while(mul <= MAX){
        cnt += n/mul;
        mul = mul*p;
    }
    ll val = A*p*p*p + B*p*p + C*p + D;
    ll ret = val*cnt;
    return ret;
}

int main()
{
    cin >> n >> A >> B >> C >> D;
    prime[1] = false;
    memset(prime, true, sizeof prime);
    for(ll i=2; i<l; i++){
        if(prime[i]){
            for(ll j=2*i; j<l; j+=i) prime[j] = false;
        }
    }
    for(ll i=2; i<l; i++){
        if(prime[i]){
            lst.push_back(i);
            plst.push_back(i);
        }
    }
    ll nows = 1;
    ll ans = 0;
    while(nows <= MAX){
        bits.reset();
        if(nows == 1) bits[1] = 1;
        for(ll i=0; i<plst.size(); i++){
            while(lst[i]+plst[i]<=nows+sz-1){
                bits[lst[i]+plst[i]-nows+1] = 1;
                lst[i] += plst[i];
            }
        }
        for(ll i=1; i<=sz; i++){
            if(bits[i] == 1) continue;
            ans += calc(i+nows-1);
        }
        nows+=sz;
    }
    cout << ans;
}


#include <bits/stdc++.h>

using namespace std;

#define ll unsigned int
#define MAX 3e8
const int l = 17400;
const int sz = 10000000;
ll n, A, B, C, D;
bitset<sz+5> bits;
bool prime[l];
vector<ll> lst, plst;

unsigned int f(unsigned int x)
{
    return A*x*x*x+B*x*x+C*x+D;
}

unsigned int calc(long long p)
{
    unsigned int ret=0,mul=1,temp;
    long long now=p;
    while(now<=3e8)
    {
        temp=n/now;
        ret+=temp;
        now*=p;
        mul++;
    }
    return ret*f(p);
}

/*ll calc(ll p)
{
    ll cnt = 0;
    ll mul = p;
    while(mul <= MAX){
        cnt += n/mul;
        mul = mul*p;
    }
    ll val = A*p*p*p + B*p*p + C*p + D;
    ll ret = val*cnt;
    return ret;
}*/

int main()
{
    cin >> n >> A >> B >> C >> D;
    prime[1] = false;
    memset(prime, true, sizeof prime);
    for(ll i=2; i<l; i++){
        if(prime[i]){
            for(ll j=2*i; j<l; j+=i) prime[j] = false;
        }
    }
    for(ll i=2; i<l; i++){
        if(prime[i]){
            lst.push_back(i);
            plst.push_back(i);
        }
    }
    ll nows = 1;
    ll ans = 0;
    while(nows <= MAX){
        bits.reset();
        if(nows == 1) bits[1] = 1;
        for(ll i=0; i<plst.size(); i++){
            while(lst[i]+plst[i]<=nows+sz-1){
                bits[lst[i]+plst[i]-nows+1] = 1;
                lst[i] += plst[i];
            }
        }
        for(ll i=1; i<=sz; i++){
            if(bits[i] == 1) continue;
            ans += calc(i+nows-1);
        }
        nows+=sz;
    }
    cout << ans;
}


#include <bits/stdc++.h>

using namespace std;

#define ll unsigned long long
#define MAX 3e8
const int l = 17400;
const int sz = 10000000;
ll n, A, B, C, D;
bitset<sz+5> bits;
bool prime[l];
vector<int> lst, plst;

ll calc(ll p)
{
    ll cnt = 0;
    ll mul = p;
    while(mul <= MAX){
        cnt += n/mul;
        mul = mul*p;
    }
    ll val = A*p*p*p + B*p*p + C*p + D;
    ll ret = val*cnt;
    return ret;
}

int main()
{
    cin >> n >> A >> B >> C >> D;
    prime[1] = false;
    memset(prime, true, sizeof prime);
    for(int i=2; i<l; i++){
        if(prime[i]){
            for(int j=2*i; j<l; j+=i) prime[j] = false;
        }
    }
    for(int i=2; i<l; i++){
        if(prime[i]){
            lst.push_back(i);
            plst.push_back(i);
        }
    }
    int nows = 1;
    ll ans = 0;
    while(nows <= MAX){
        bits.reset();
        if(nows == 1) bits[1] = 1;
        for(int i=0; i<plst.size(); i++){
            while(lst[i]+plst[i]<=nows+sz-1){
                bits[lst[i]+plst[i]-nows+1] = 1;
                lst[i] += plst[i];
            }
        }
        for(int i=1; i<=sz; i++){
            if(bits[i] == 1) continue;
            ans += calc(i+nows-1);
        }
        nows+=sz;
    }
    cout << ans;
}


#include<bits/stdc++.h>

using namespace std;

#define pb push_back
#define fo(i, n) for(int i = 1; i <= n; ++i)

typedef long long ll;

const int N = 500500;
const int mod = 1e9 + 7;
const ll inf = 1e18;

bitset<100010011> bit;
ll n;
unsigned int A, B, C, D;
unsigned int f(unsigned int x) {
    return A * x * x * x + B * x * x + C * x + D;
}
inline unsigned int calc(unsigned int x) {
    if(x > n) return 0;
    unsigned int y = n, ans = 0;
    while(y) ans += ( y /= x);
    return ans * f(x);
}
unsigned int ans = 0;
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> A >> B >> C >> D;
    ans = calc(2) + calc(3);
    int x;
    int ind = 0;
    int fail = 0;
    int f = 0;
    int v = sqrt(300000000) + 1;
    for(int i = 5; i <= n; i += 6, ind += 2) {
        if(!bit[ind]) {
            ans += calc(i);
            if(i <= v) for(int j = i * i; j <= n; j += 2 * i) {
                f = j % 3;
                if(f == 0) continue;
                if(f == 2) bit[(j - 5) / 3] = 1;
                else bit[(j - 7) / 3 + 1] = 1;
            }
        }
        if(!bit[ind + 1]) {
            x = i + 2;
            ans += calc(x);
            if(x <= v) for(int j = x * x; j <= n; j += 2 * x) {
                f = j % 3;
                if(f == 0) continue;
                if(f == 2) bit[(j - 5) / 3] = 1;
                else bit[(j - 7) / 3 + 1] = 1;
            }
        }
    }
    cout << ans;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define pb push_back
#define fo(i, n) for(int i = 1; i <= n; ++i)

typedef long long ll;

const int N = 500500;
const int mod = 1e9 + 7;
const ll inf = 1e18;

bitset<100000001> bit;
unsigned int n;
unsigned int A, B, C, D;
unsigned int f(unsigned int x) {
    return A * x * x * x + B * x * x + C * x + D;
}
inline unsigned int calc(unsigned int x) {
    if(x > n) return 0;
    unsigned int y = x, ans = 0;
    while(y <= n) ans += n / y, y *= x;
    return ans * f(x);
}
unsigned int ans = 0;
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> A >> B >> C >> D;
    ans = calc(2) + calc(3);
    int x;
    int ind = 0;
    int fail = 0;
    int f = 0;
    for(int i = 5; i <= n; i += 6, ind += 2) {
        if(!bit[ind]) {
            ans += calc(i);
            if(i * 1ll * i <= n) for(int j = i * i; j <= n; j += 2 * i) {
                f = j % 3;
                if(f == 0) continue;
                if(f == 2) bit[(j - 5) / 3] = 1;
                else bit[(j - 7) / 3 + 1] = 1;
            }
        }
        if(!bit[ind + 1]) {
            x = i + 2;
            ans += calc(x);
            if(x * 1ll * x <= n) for(int j = x * x; j <= n; j += 2 * x) {
                f = j % 3;
                if(f == 0) continue;
                if(f == 2) bit[(j - 5) / 3] = 1;
                else bit[(j - 7) / 3 + 1] = 1;
            }
        }
    }
    cout << ans;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define uint unsigned int
#define rint register int
inline int rf(){int r;int s=0,c;for(;!isdigit(c=getchar());s=c);for(r=c^48;isdigit(c=getchar());(r*=10)+=c^48);return s^45?r:-r;}
bitset<100000032> _b; int n; uint A, B, C, D, Ans;
inline uint f(int p){
    return((A*p+B)*p+C)*p+D;
}
inline int cnt(int p, int n){
    int r=0;
    for(;n/=p;r+=n);
    return r;
}
inline auto b(int i)->decltype(_b[0]){
    return _b[(i&1)&&(i%6!=3)?i/6<<1|((i%6)>1):0];
}
inline auto b2(int i)->decltype(_b[0]){
    return _b[i/6<<1|1];
}
inline auto b3(int i)->decltype(_b[0]){
    return _b[i/6<<1];
}

int main()
{
    n = rf();
    A = rf();
    B = rf();
    C = rf();
    D = rf();
    _b[0] = 1;
    Ans = cnt(2,n)*f(2)+cnt(3,n)*f(3);
    for(rint i = 5, j, z, c, w; i <= n; i += 4){
        if(!b2(i))
        {
            Ans += cnt(i,n)*f(i);
            if(i <= 20000){
                w = i + i;
                c = w % 6;
                z = (i * i) % 6;
                if(c == 0){
                    if(z == 1){
                        for(j = i * i; j <= n; j += w){
                            b3(j) = 1;
                        }
                    }else if(z == 5){
                        for(j = i * i; j <= n; j += w){
                            b2(j) = 1;
                        }
                    }
                }else if(c == 2){
                    if(z == 1){
                        for(j = i * i; j <= n; j += w){
                            b3(j) = 1;
                            j += w + w;
                            if(j <= n){
                                b2(j) = 1;
                            }
                        }
                    }else if(z == 5){
                        for(j = i * i; j <= n; j += w + w){
                            b2(j) = 1;
                            j += w;
                            if(j <= n){
                                b3(j) = 1;
                            }
                        }
                    }
                }else if(c == 4){
                    if(z == 1){
                        for(j = i * i; j <= n; j += w + w){
                            b3(j) = 1;
                            j += w;
                            if(j <= n){
                                b2(j) = 1;
                            }
                        }
                    }else if(z == 5){
                        for(j = i * i; j <= n; j += w){
                            b2(j) = 1;
                            j += w + w;
                            if(j <= n){
                                b3(j) = 1;
                            }
                        }
                    }
                }
            }
        }
        i += 2;
        if(i <= n && !b3(i))
        {
            Ans += cnt(i,n)*f(i);
            if(i <= 20000){
                w = i + i;
                c = w % 6;
                z = (i * i) % 6;
                if(c == 0){
                    if(z == 1){
                        for(j = i * i; j <= n; j += w){
                            b3(j) = 1;
                        }
                    }else if(z == 5){
                        for(j = i * i; j <= n; j += w){
                            b2(j) = 1;
                        }
                    }
                }else if(c == 2){
                    if(z == 1){
                        for(j = i * i; j <= n; j += w){
                            b3(j) = 1;
                            j += w + w;
                            if(j <= n){
                                b2(j) = 1;
                            }
                        }
                    }else if(z == 5){
                        for(j = i * i; j <= n; j += w + w){
                            b2(j) = 1;
                            j += w;
                            if(j <= n){
                                b3(j) = 1;
                            }
                        }
                    }
                }else if(c == 4){
                    if(z == 1){
                        for(j = i * i; j <= n; j += w + w){
                            b3(j) = 1;
                            j += w;
                            if(j <= n){
                                b2(j) = 1;
                            }
                        }
                    }else if(z == 5){
                        for(j = i * i; j <= n; j += w){
                            b2(j) = 1;
                            j += w + w;
                            if(j <= n){
                                b3(j) = 1;
                            }
                        }
                    }
                }
            }
        }
    }
    printf("%u\n",Ans);
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define pb push_back
#define fo(i, n) for(int i = 1; i <= n; ++i)

typedef long long ll;

const int N = 500500;
const int mod = 1e9 + 7;
const ll inf = 1e18;

bitset<100000001> bit;
int n;
unsigned int A, B, C, D;
unsigned int f(unsigned int x) {
    return A * x * x * x + B * x * x + C * x + D;
}
inline unsigned int calc(ll x) {
    if(x > n) return 0;
    unsigned int y = x, ans = 0;
    while(y <= n) ans += n / y, y *= x;
    return ans * f(x);
}
unsigned int ans = 0;
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> A >> B >> C >> D;
    ans = calc(2) + calc(3);
    int x;
    int ind = 0;
    int fail = 0;
    int f = 0;
    for(int i = 5; i <= n; i += 6, ind += 2) {
        if(!bit[ind]) {
            ans += calc(i);
            if(i * 1ll * i <= n) for(int j = i * i; j <= n; j += 2 * i) {
                f = j % 3;
                if(f == 0) continue;
                if(f == 2) bit[(j - 5) / 3] = 1;
                else bit[(j - 7) / 3 + 1] = 1;
            }
        }
        if(!bit[ind + 1]) {
            x = i + 2;
            ans += calc(x);
            if(x * 1ll * x <= n) for(int j = x * x; j <= n; j += 2 * x) {
                f = j % 3;
                if(f == 0) continue;
                if(f == 2) bit[(j - 5) / 3] = 1;
                else bit[(j - 7) / 3 + 1] = 1;
            }
        }
    }
    cout << ans;

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define pb push_back
#define fo(i, n) for(int i = 1; i <= n; ++i)

typedef long long ll;

const int N = 500500;
const int mod = 1e9 + 7;
const ll inf = 1e18;

bitset<100010011> bit;
ll n;
unsigned int A, B, C, D;
unsigned int f(unsigned int x) {
    return A * x * x * x + B * x * x + C * x + D;
}
inline unsigned int calc(unsigned int x) {
    if(x > n) return 0;
    unsigned int y = x, ans = 0;
    while(y <= n) ans += n / y, y *= x;
    return ans * f(x);
}
unsigned int ans = 0;
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> A >> B >> C >> D;
    ans = calc(2) + calc(3);
    int x;
    int ind = 0;
    int fail = 0;
    int f = 0;
    int v = sqrt(300000000) + 1;
    for(int i = 5; i <= n; i += 6, ind += 2) {
        if(!bit[ind]) {
            ans += calc(i);
            if(i <= v) for(int j = i * i; j <= n; j += 2 * i) {
                f = j % 3;
                if(f == 0) continue;
                if(f == 2) bit[(j - 5) / 3] = 1;
                else bit[(j - 7) / 3 + 1] = 1;
            }
        }
        if(!bit[ind + 1]) {
            x = i + 2;
            ans += calc(x);
            if(x <= v) for(int j = x * x; j <= n; j += 2 * x) {
                f = j % 3;
                if(f == 0) continue;
                if(f == 2) bit[(j - 5) / 3] = 1;
                else bit[(j - 7) / 3 + 1] = 1;
            }
        }
    }
    cout << ans;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef unsigned int ll;

#define SZ 3085

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

ll N, a, b, c, d, ans, z;
ll pot[SZ];
int pr[SZ];

ll f(ll x) {
    ll ret = (a * x + b);
    ret = (ret * x + c);
    ret = (ret * x + d);
    return ret;
}

void jonson(int limit) {
    if(limit < 2) return;
    z = 1;

    int sqrt = (int) std::sqrt(limit);
    int segment_size = sqrt;

    ans = (ans + (N / pot[0]) * f(2));
    int s = 3, n = 3;

    char is_prime[sqrt + 1];
    memset(is_prime, 1, sizeof is_prime);

    for (int i = 2; i * i <= sqrt; ++i)
        if (is_prime[i])
            for (int j = i * i; j <= sqrt; j += i)
                is_prime[j] = 0;

    char sieve[segment_size];
    int primes[SZ], next[SZ], id = 0;

    for (int low = 0; low <= limit; low += segment_size) {
        memset(sieve, 1, sizeof sieve);
        int high = min(low + segment_size - 1, limit);

        for (; s * s <= high; s += 2) {
            if (is_prime[s]) {
                primes[id] = (s);
                next[id++] = (s * s - low);
            }
        }

        for (int i = 0; i < id; ++i) {
            int j = next[i];
            for (int k = primes[i] << 1; j < segment_size; j += k)
                sieve[j] = 0;
            next[i] = j - segment_size;
        }

        for (; n <= high; n += 2)
            if (sieve[n - low]) {
                if(limit == N && z < SZ) {
                    pr[z] = n;
                    pot[z++] = n;
                } else z++;
                ans = (ans + (N / ((z <= SZ) ? pot[z-1] : n)) * f(n));
            }
    }
}

int main() {
    scanf("%u %u %u %u %u", &N, &a, &b, &c, &d);

    pot[0] = pr[0] = 2;
    jonson(N);
    for(int p = 2; p < 32; p++) {
        for(int i = 0;; i++) {
            pot[i] = pot[i] * pr[i];
            if(pot[i] > N) {
                if(i) jonson(pr[i-1]);
                break;
            }
        }
    }

    printf("%u\n", ans);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef unsigned int ll;

#define SZ 3085

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

ll N, a, b, c, d, ans, z;
ll pot[SZ];
int pr[SZ];

ll f(ll x) {
    ll ret = (a * x + b);
    ret = (ret * x + c);
    ret = (ret * x + d);
    return ret;
}

void jonson(int limit) {
    if(limit < 2) return;
    z = 1;

    int sqrt = (int) std::sqrt(limit);
    int segment_size = sqrt;

    ans = (ans + (N / pot[0]) * f(2));
    int s = 3, n = 3;

    char is_prime[sqrt + 1];
    memset(is_prime, 1, sizeof is_prime);

    for (int i = 2; i * i <= sqrt; ++i)
        if (is_prime[i])
            for (int j = i * i; j <= sqrt; j += i)
                is_prime[j] = 0;

    char sieve[segment_size];
    int primes[SZ], next[SZ], id = 0;

    for (int low = 0; low <= limit; low += segment_size) {
        memset(sieve, 1, sizeof sieve);
        int high = min(low + segment_size - 1, limit);

        for (; s * s <= high; s += 2) {
            if (is_prime[s]) {
                primes[id] = (s);
                next[id++] = (s * s - low);
            }
        }

        for (int i = 0; i < id; ++i) {
            int j = next[i];
            for (int k = primes[i] << 1; j < segment_size; j += k)
                sieve[j] = 0;
            next[i] = j - segment_size;
        }

        for (; n <= high; n += 2)
            if (sieve[n - low]) {
                if(limit == N && z < SZ) {
                    pr[z] = n;
                    pot[z++] = n;
                } else z++;
                ans = (ans + (N / ((z <= SZ) ? pot[z-1] : n)) * f(n));
            }
    }
}

int main() {
    scanf("%u %u %u %u %u", &N, &a, &b, &c, &d);

    pot[0] = pr[0] = 2;
    jonson(N);
    for(int p = 2; p < 30; p++) {
        for(int i = 0;; i++) {
            long long tmp = 1LL * pot[i] * pr[i];
            pot[i] = pot[i] * pr[i];
            if(tmp > N) {
                if(i) jonson(pr[i-1]);
                break;
            }
        }
    }

    printf("%u\n", ans);
    return 0;
}


#include <bits/stdc++.h>

#define MOD (1LL << 32)

using namespace std;
typedef long long ll;

#define SZ 3085

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

ll N, a, b, c, d, ans, z;
ll pot[SZ];
int pr[SZ];

ll f(ll x) {
    ll ret = (a * x + b) % MOD;
    ret = (ret * x + c) % MOD;
    ret = (ret * x + d) % MOD;
    return ret;
}

void jonson(int limit) {
    if(limit < 2) return;
    z = 1;

    int sqrt = (int) std::sqrt(limit);
    int segment_size = sqrt;

    ans = (ans + (N / pot[0]) * f(2)) % MOD;
    int s = 3, n = 3;

    char is_prime[sqrt + 1];
    memset(is_prime, 1, sizeof is_prime);

    for (int i = 2; i * i <= sqrt; ++i)
        if (is_prime[i])
            for (int j = i * i; j <= sqrt; j += i)
                is_prime[j] = 0;

    char sieve[segment_size];
    int primes[SZ], next[SZ], id = 0;

    for (int low = 0; low <= limit; low += segment_size) {
        memset(sieve, 1, sizeof sieve);
        int high = min(low + segment_size - 1, limit);

        for (; s * s <= high; s += 2) {
            if (is_prime[s]) {
                primes[id] = (s);
                next[id++] = (s * s - low);
            }
        }

        for (int i = 0; i < id; ++i) {
            int j = next[i];
            for (int k = primes[i] << 1; j < segment_size; j += k)
                sieve[j] = 0;
            next[i] = j - segment_size;
        }

        for (; n <= high; n += 2)
            if (sieve[n - low]) {
                if(limit == N && z < SZ) {
                    pr[z] = n;
                    pot[z++] = n;
                } else z++;
                ans = (ans + (N / ((z <= SZ) ? pot[z-1] : n)) * f(n)) % MOD;
            }
    }
}

int main() {
    scanf("%lld %lld %lld %lld %lld", &N, &a, &b, &c, &d);

    pot[0] = pr[0] = 2;
    jonson(N);
    for(int p = 2; p < 32; p++) {
        for(int i = 0;; i++) {
            pot[i] = pot[i] * pr[i];
            if(pot[i] > N) {
                if(i) jonson(pr[i-1]);
                break;
            }
        }
    }

    printf("%lld\n", ans);
    return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define ll long long
//#define int ll
#define ld long double
#define endl '\n'
#define TIME 1.0*clock()/CLOCKS_PER_SEC

using namespace std;

mt19937 gen(chrono::system_clock::now().time_since_epoch().count());

const ll M = 1ll<<32;
const int M1 = 9979997;
const int N = 3e8 + 7;

vector<int> pr;
ll n, a, b, c, d;

ll Fn(ll x){
    ll res = 0, cur = 1;
    res += cur*a;
    res %= M;
    cur *= x;
    cur %= M;
    res += cur*b;
    res %= M;
    cur *= x;
    cur %= M;
    res += cur*c;
    res %= M;
    cur *= x;
    cur %= M;
    res += cur*d;
    res %= M;
    return res;
}

ll s(ll x){
    ll res = 0;
    vector<ll> kol;
    kol.pb(0);
    for (ll i = x, k = 1; i <= n; i *= x, k++)
        kol.pb(n/i);
    for (ll i = x, k = 1; i <= n; i *= x, k++){
        vector<bool> f(50, 1);
        ll cur = n/i - (k + 1 < kol.size() ? kol[k + 1] : 0);
        res += cur*k*Fn(x);
        res %= M;
    }
    return res;
}

int ans;

    const int SQRT_MAXN = 100000; // ������ �� ������������� �������� N
const int S = 10000;
bool nprime[SQRT_MAXN], bl[S];
int primes[SQRT_MAXN], cnt;
main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef LOCAL
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    cin >> n >> d >> c >> b >> a;
//    if (n >= 2e7) return 1/0;
	int nsqrt = (int) sqrt (N + .0);
	for (int i=2; i<=nsqrt; ++i)
		if (!nprime[i]) {
//			ans += s(i);
//                ans %= M;
			primes[cnt++] = i;
			if (i * 1ll * i <= nsqrt)
				for (int j=i*i; j<=nsqrt; j+=i)
					nprime[j] = true;
		}

	int result = 0;
	for (int k=0, maxk=N/S; k<=maxk; ++k) {
		memset (bl, 0, sizeof bl);
		int start = k * S;
		for (int i=0; i<cnt; ++i) {
			int start_idx = (start + primes[i] - 1) / primes[i];
			int j = max(start_idx,2) * primes[i] - start;
			for (; j<S; j+=primes[i])
				bl[j] = true;
		}
		if (k == 0)
			bl[0] = bl[1] = true;
		for (int i=0; i<S && start+i<=N; ++i)
			if (!bl[i]){
				++result;
                ans += s(start + i);
                ans %= M;
			}
	}
    cout << ans;
    return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define ll long long
//#define int ll
#define ld long double
#define endl '\n'
#define TIME 1.0*clock()/CLOCKS_PER_SEC

using namespace std;

mt19937 gen(chrono::system_clock::now().time_since_epoch().count());

const ll M = 1ll<<32;
const int N = 3e8 + 7;

vector<int> pr;
ll n, a, b, c, d;

ll Fn(ll x){
    ll res = 0, cur = 1;
    res += cur*a;
    res %= M;
    cur *= x;
    cur %= M;
    res += cur*b;
    res %= M;
    cur *= x;
    cur %= M;
    res += cur*c;
    res %= M;
    cur *= x;
    cur %= M;
    res += cur*d;
    res %= M;
    return res;
}

ll s(ll x){
    ll res = 0;
    vector<ll> kol;
    kol.pb(0);
    for (ll i = x, k = 1; i <= n; i *= x, k++)
        kol.pb(n/i);
    for (ll i = x, k = 1; i <= n; i *= x, k++){
        vector<bool> f(50, 1);
        ll cur = n/i - (k + 1 < kol.size() ? kol[k + 1] : 0);
        res += cur*k*Fn(x);
        res %= M;
    }
    return res;
}

int ans;

    const int SQRT_MAXN = 1000000; // ������ �� ������������� �������� N
const int S = 100000;
bool nprime[SQRT_MAXN], bl[S];
int primes[SQRT_MAXN], cnt;
main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef LOCAL
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    cin >> n >> d >> c >> b >> a;
//    if (n >= 2e7) return 1/0;
	int nsqrt = (int) sqrt (N + .0);
	for (int i=2; i<=nsqrt; ++i)
		if (!nprime[i]) {
//			ans += s(i);
//                ans %= M;
			primes[cnt++] = i;
			if (i * 1ll * i <= nsqrt)
				for (int j=i*i; j<=nsqrt; j+=i)
					nprime[j] = true;
		}

	int result = 0;
	for (int k=0, maxk=N/S; k<=maxk; ++k) {
		memset (bl, 0, sizeof bl);
		int start = k * S;
		for (int i=0; i<cnt; ++i) {
			int start_idx = (start + primes[i] - 1) / primes[i];
			int j = max(start_idx,2) * primes[i] - start;
			for (; j<S; j+=primes[i])
				bl[j] = true;
		}
		if (k == 0)
			bl[0] = bl[1] = true;
		for (int i=0; i<S && start+i<=N; ++i)
			if (!bl[i]){
				++result;
                ans += s(start + i);
                ans %= M;
			}
	}
    cout << ans;
    return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define ll long long
//#define int ll
#define ld long double
#define endl '\n'
#define TIME 1.0*clock()/CLOCKS_PER_SEC

using namespace std;

mt19937 gen(chrono::system_clock::now().time_since_epoch().count());

const ll M = 1ll<<32;
const int N = 3e8 + 7;

vector<int> pr;
ll n, a, b, c, d;

ll Fn(ll x){
    ll res = 0, cur = 1;
    res += cur*a;
    res %= M;
    cur *= x;
    cur %= M;
    res += cur*b;
    res %= M;
    cur *= x;
    cur %= M;
    res += cur*c;
    res %= M;
    cur *= x;
    cur %= M;
    res += cur*d;
    res %= M;
    return res;
}

ll s(ll x){
    ll res = 0;
    for (ll i = x; i <= n; i *= x){
        ll cur = n/i;
        res += cur*Fn(x);
        res %= M;
    }
    return res;
}

ll ans;

    const int SQRT_MAXN = 1000000; // ������ �� ������������� �������� N
const int S = 100000;
bool nprime[SQRT_MAXN], bl[S];
int primes[SQRT_MAXN], cnt;
main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef LOCAL
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    cin >> n >> d >> c >> b >> a;
//    if (n >= 2e7) return 1/0;
	int nsqrt = (int) sqrt (N + .0);
	for (int i=2; i<=nsqrt; ++i)
		if (!nprime[i]) {
//			ans += s(i);
//                ans %= M;
			primes[cnt++] = i;
			if (i * 1ll * i <= nsqrt)
				for (int j=i*i; j<=nsqrt; j+=i)
					nprime[j] = true;
		}

	int result = 0;
	for (int k=0, maxk=N/S; k<=maxk; ++k) {
		memset (bl, 0, sizeof bl);
		int start = k * S;
		for (int i=0; i<cnt; ++i) {
			int start_idx = (start + primes[i] - 1) / primes[i];
			int j = max(start_idx,2) * primes[i] - start;
			for (; j<S; j+=primes[i])
				bl[j] = true;
		}
		if (k == 0)
			bl[0] = bl[1] = true;
		for (int i=0; i<S && start+i<=N; ++i)
			if (!bl[i]){
				++result;
                ans += s(start + i);
                ans %= M;
			}
	}
    cout << ans;
    return 0;
}