#include <iostream>
using namespace std;
void Lis_inc(int a[],int n)
{
int i,j;
int *f = new int [n];
for (i = 0;i < n;i++)
{
f[i] = 1;
for (j = 0;j < i ;j++)
if (a[j] < a[i])
f[i] = max(f[i],f[j]+1);
}
int max=-99999;
for (i = 0;i < n;i++)
if(max < f[i])
max = f[i];
cout << max << endl;
}
void Lis_dec(int a[],int n)
{
int i,j;
int *f = new int [n];
for (i = n-1;i >= 0;i--)
{
f[i] = 1;
for (j = n-1;j > i ;j--)
if (a[i] > a[j])
f[i] = max(f[i],f[j]+1);
}
int max = -999999;
for (i = 0;i < n;i++)
if(max < f[i])
max = f[i];
cout << max << endl;
}
int main()
{
int a[]={1,7,3,5,9,4,8,2};
Lis_inc(a,8);
Lis_dec(a,8);
return 0;
}