#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int List[n];
for(int i = 0; i < n; i++)
{
cin>>List[i];
}
int LIS[n];
for(int i = 0; i < n; i++)
{
LIS[i] = 1;
}
for(int i = 1; i < n; i++)
{
for(int j = 0; j < i; j++)
{
if(List[i] > List[j])
{
LIS[i] = max(LIS[i], 1+LIS[j]);
}
}
}
for(int i = 0; i < n; i++)
{
cout<<LIS[i]<<" ";
}
cout<<endl;
int mx = INT_MIN;
for(int i = 0; i< n; i++)
{
if(LIS[i] > mx)mx = LIS[i];
}
cout<<mx<<endl;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkKewogICAgaW50IG47CiAgICBjaW4+Pm47CiAgICBpbnQgTGlzdFtuXTsKICAgIGZvcihpbnQgaSA9IDA7IGkgPCBuOyBpKyspCiAgICB7CiAgICAgICAgY2luPj5MaXN0W2ldOwogICAgfQoKICAgIGludCBMSVNbbl07CiAgICBmb3IoaW50IGkgPSAwOyBpIDwgbjsgaSsrKQogICAgewogICAgICAgIExJU1tpXSA9IDE7CiAgICB9CgogICAgZm9yKGludCBpID0gMTsgaSA8IG47IGkrKykKICAgIHsKICAgICAgICBmb3IoaW50IGogPSAwOyBqIDwgaTsgaisrKQogICAgICAgIHsKICAgICAgICAgICAgaWYoTGlzdFtpXSA+IExpc3Rbal0pCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIExJU1tpXSA9IG1heChMSVNbaV0sIDErTElTW2pdKTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KCiAgICBmb3IoaW50IGkgPSAwOyBpIDwgbjsgaSsrKQogICAgewogICAgICAgIGNvdXQ8PExJU1tpXTw8IiAiOwogICAgfQogICAgY291dDw8ZW5kbDsKICAgIGludCBteCA9IElOVF9NSU47CiAgICBmb3IoaW50IGkgPSAwOyBpPCBuOyBpKyspCiAgICB7CiAgICAgICAgaWYoTElTW2ldID4gbXgpbXggPSBMSVNbaV07CiAgICB9CiAgICBjb3V0PDxteDw8ZW5kbDsKCgoKCgoKCgoKfQo=