#include <iostream> using namespace std; int main() { int n, s = 0, ss = 1; cin >> n; for (int i = 1; i <= n; i++) { ss *= i; ss %= 1000000; s += ss; s %= 1000000; } cout << s; return 0; }