// #define DEBUGGING #include using namespace std; #define endl '\n' #define ALL(V) (V).begin(), (V).end() #define ALLR(V) (V).rbegin(), (V).rend() template using V = vector; template using VV = V>; using ll = int64_t; using ull = uint64_t; using PLL = pair; template const T& var_min(const T &t) { return t; } template const T& var_max(const T &t) { return t; } template const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); } template const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); } template void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); } template void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); } template const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); } template void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); } namespace init__ { struct InitIO { InitIO() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(30); } } init_io; } #ifdef DEBUGGING // #include "../debug/debug.cpp" #include "../../debug/debug.cpp" #else #define DEBUG(...) 0 #define DEBUG_SEPARATOR_LINE 0 #endif template T make_v(T init) { return init; } template auto make_v(T init, size_t s, Tail... tail) { #define rec make_v(init, tail...) return V(s, rec); #undef rec } const ll mod = 1e9 + 7; template class Combination { private: ll N; V factv, ifactv; public: Combination(ll N) : N(N), factv(N + 1, 1), ifactv(N + 1) { for(ll i = 1; i <= N; i++) factv[i] = factv[i - 1] * i % MOD; ifactv.back() = inv(factv.back()); for(ll i = N - 1; 0 <= i; i--) ifactv[i] = (i + 1) * ifactv[i + 1] % MOD; } ll fact(ll n) { return factv[n]; } ll ifact(ll n) { return ifactv[n]; } ll pow(ll a, ll b) { return b ? (b & 1 ? a : 1) * pow(a * a % MOD, b / 2) % MOD : 1; } ll inv(ll a) { return pow(a, MOD - 2); } ll comb(ll n, ll k) { return factv[n] * ifactv[n - k] % MOD * ifactv[k] % MOD; } }; Combination C(1e6 + 10); int main() { ll N; cin >> N; ll dstnct = (N - 2) % mod * ((N - 3) % mod) % mod * C.ifact(2) % mod; ll same3 = (N - 1) % 3 == 0; ll same2 = (N - 2) / 2 % mod; (same2 += mod - same3) %= mod; DEBUG(make_tuple(dstnct, same2, same3)); dstnct = (dstnct + 2 * mod - 3 * same2 % mod - same3) % mod; DEBUG(dstnct); (dstnct *= C.ifact(3)) %= mod; cout << (dstnct + same2 + same3) % mod << endl; return 0; }