#include using namespace std; const int maxn = 5005005; int v[maxn], pa[maxn], mx[maxn]; int fnd(int u) { return u == pa[u] ? u : (pa[u] = fnd(pa[u])); } void mrg(int u, int v) { u = fnd(u), v = fnd(v); pa[u] = v; mx[v] = max(mx[u], mx[v]); } int main(void) { int n; scanf("%d", &n); for (int i=0; i<=n; i++) pa[i] = mx[i] = i; v[0] = 1; for (int i=0; i