#include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; long long MOD = 1000000007; typedef long long ll; int main(int argc, char *argv[]) { ll N; cin >> N; N--; ll n, k; n = (N / 6) % MOD; k = N % 6; ll ans = (3 * n * (n + 1)) % MOD; ans += (n * (k - 3) + MOD) % MOD; if (k == 3 || k == 4) ans += 1; if (k == 5) ans += 2; ans %= MOD; cout << ans << endl; return 0; }