import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
class Solution {
public static void main(String args[]) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
int N = Integer.parseInt(br.readLine());
int[] arr = new int[N];
int[] dp = new int[N];
st = new StringTokenizer(br.readLine());
for (int i = 0; i < N; i++) {
arr[i] = Integer.parseInt(st.nextToken());
}
dp[0] = 1;
int maxIndex;
int maxValue;
for (int i = 1; i < N; i++) {
if (arr[i] == arr[i - 1]) {
dp[i] = dp[i - 1];
} else {
maxIndex = -1;
maxValue = 1;
for (int j = i - 1; j >= 0; j--) {
if (arr[j] < arr[i] && maxValue <= dp[j]) {
maxValue = dp[j];
maxIndex = j;
}
}
dp[i] = maxIndex == -1 ? 1 : dp[maxIndex] + 1;
}
}
maxValue = 0;
for (int i = 0; i < N; i++) {
maxValue = maxValue > dp[i] ? maxValue : dp[i];
}
System.out.print(maxValue);
}
}