#include #include using namespace std; const int MOD = 1000000007; int n, ans; int main() { // freopen("number.in", "r", stdin); // freopen("number.out", "w", stdout); scanf("%d", &n); for (int i = 1; i <= n; ++i) { ans = (0LL + ans + 1LL * i * __builtin_popcount(i) % MOD) % MOD; } printf("%d\n", ans); // printf("%.3lf ms\n", 1000.0 * clock () / CLOCKS_PER_SEC); return 0; }