#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define N (1000000000+7) //#define N 998244353 #define INF 1e16 typedef long long ll; typedef pair P; typedef pair Q; const int inf = (int)1e9; ll gcd(ll a, ll b) { if (b > a) { ll tmp = b; b = a; a = tmp; } if (a%b == 0)return b; else return gcd(b, a%b); } bool prime[1000010]; void furui() { int i = 2; while (i <= 1000000) { int j = 2; while (j*j <= i && !prime[i]) { if (i%j == 0) { prime[i] = true; break; } else j++; } int z = 2; while (!prime[i]) { if (i*z <= 1000000) { prime[i*z] = true; z++; } else break; } i++; } } int main(void){ furui(); int n; cin>>n; ll ans = 0; vectorp; for(ll i=2;i<=n;i++){ if(!prime[i]){ p.push_back(i); } } for(int i=0;i