#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include constexpr int MOD{1'000'000'007}; constexpr int MOD2{998'244'353}; constexpr int INF{1'000'000'000}; //1e9 constexpr int NIL{-1}; constexpr long long LINF{1'000'000'000'000'000'000}; // 1e18 constexpr long double EPS{1E-10L}; using namespace std::literals; namespace ranges = std::ranges; namespace views = ranges::views; template bool chmax(T &a, const S &b){ if(a < b){a = b; return true;} return false; } template bool chmin(T &a, const S &b){ if(b < a){a = b; return true;} return false; } template bool inside(T x, T lx, T rx){ //semi-open return (ranges::clamp(x, lx, rx-1) == x); } template bool inside(T x, T y, T lx, T rx, T ly, T ry){ return inside(x, lx, rx) && inside(y, ly, ry); } template std::istream &operator>>(std::istream &is, std::pair &p){ return is >> p.first >> p.second; } template std::ostream &operator<<(std::ostream &os, const std::pair &p){ return os << p.first << " " << p.second; } template std::istream &operator>>(std::istream &is, std::vector &v){ {for(auto &e: v) is >> e;} return is; } template void print_container(const Container &c, std::string sep = " "s, std::string end = "\n"s){ for(int i{int(std::size(c))}; auto e: c) std::cout << e << (--i ? sep : end); } std::string yesno(bool x){return x ? "Yes"s : "No"s;} int main(){ int N; std::cin >> N; auto A{1LL}, B{0LL}, ans{1LL}; for(int i{2}; i <= N; ++i){ ans = i * A % MOD; ranges::swap(A, B); (A += ans) %= MOD; } std::cout << ans << std::endl; return 0; }