#include "testlib.h"
#include <iostream>
#include <algorithm>
using namespace std;
int n, a[500010], f[500010], cnt, sum;
int main(int argc, char* argv[]) {
setName("Interactor LCS");
registerInteraction(argc, argv);
rnd.setSeed(time(NULL));
int n = rnd.next(1,100000);
cout << n << endl;
for (int i = 1; i <= n; i ++ )
{
a[i] = rnd.next(1000000000);
cout << a[i] << " ";
}
cin >> sum;
cnt = 0;
for (int i = 1; i <= n; i++) {
if (f[cnt] < a[i]) {
f[++cnt] = a[i];
}
else {
*(lower_bound(f + 1, f + cnt, a[i])) = a[i];
}
}
if (sum != cnt)
{
quitf(_wa, "LCS expected %d, found %d",cnt, sum);
}
else
{
quitf(_ok, "answer of LCS is %d",cnt);
}
return 0;
}