#include using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; assert(1 <= n && n <= 1000000); // Ensure n is within the given bounds vector r(n + 1); // Initialize r[i] to i for all i for(int i = 0; i <= n; i++){ r[i] = i; } // Calculate the totient function for each number up to n for(int i = 2; i <= n; i++){ if(r[i] != i) continue; // Skip if i is not a prime for(int j = i; j <= n; j += i){ r[j] -= r[j] / i; // Apply the formula for the totient function } } long long ans = 0; // Sum up the given function involving the totient for each y from 1 to n for(int y = 1; y <= n; y++){ ans += ((n / y) - 1) * (r[y] - 1); } cout << ans << endl; return 0; }