// #牛客春招刷题训练营# https://www.nowcoder.com/discuss/726480854079250432
// 其实只要理解了题目真正要求的就可以了,第一问实际上是问最长不严格递减子序列,第二问我是看的其它题解求的是最长严格递增子序列
#include <iostream>
#include <vector>
using namespace std;
int main() {
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
int n;
cin >> n;
vector<int> a(n), dp(n, 1), ddp(n, 1);//------dp[i]表示以i为起点的最长不严格递减,ddp[i]表示以i为起点最长严格递增.
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = n - 2; i >= 0; i--){
for (int j = i + 1; j < n; j++){
if (a[j] <= a[i]){
dp[i] = max(dp[j] + 1, dp[i]);
}
else{
ddp[i] = max(ddp[i], ddp[j] + 1);
}
}
}
int ans = 0;
for (int i = 0; i < n; i++){
ans = max(ans, dp[i]);
}
cout << ans << endl;
ans = 0;
for (int i = 0; i < n; i++){
ans = max(ans, ddp[i]);
}
cout << ans;
return 0;
}
// 64 位输出请用 printf("%lld")