#include <bits/stdc++.h> #define MAX 100 using namespace std; int main() { int dp1[MAX], dp2[MAX], data[MAX], i, j, ans; int n; cin >> n; for (i = 1; i <= n; i++) { cin >> data[i]; dp1[i] = 1; dp2[i] = 1; } for (i = 1; i <= n; i++) //以i为中间点,左侧有多少递增的 for (j = 1; j < i; j++) { //j每次从头开始 if (data[j] < data[i]) dp1[i] = max(dp1[j] + 1, dp1[i]); } for (i = n; i >= 1; i--) for (j = n; j > i; j--) { if (data[j] < data[i]) dp2[i] = max(dp2[j] + 1, dp2[i]); } ans = -1; for (i = 1; i <= n; i++) { int tmp = dp1[i] + dp2[i] - 1; ans = max(ans, tmp); } cout << n - ans << endl; }