#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template<typename Weight>
struct FordFulkerson {
using weight_type = Weight;
struct Edge {
int src, dst, rev;
Weight cap;
Edge(int f, int t, Weight c, int r) :
src(f), dst(t), rev(r), cap(c) {}
};
int n;
std::vector<std::vector<Edge>> adj;
const Weight INF;
explicit FordFulkerson(int _n, Weight inf = std::numeric_limits<Weight>::max() / 10)
: n(_n), adj(n), INF(inf) {}
void add_arc(const int src, const int dst, const Weight cap) {
adj[src].emplace_back(Edge(src, dst, cap, adj[dst].size()));
adj[dst].emplace_back(Edge(dst, src, 0, adj[src].size() - 1));
}
void add_edge(const int src, const int dst, const Weight cap) {
add_arc(src, dst, cap);
add_arc(dst, src, cap);
}
Weight MaximumFlow(const int s, const int t) {
Weight flow = 0;
while (true) {
std::vector<bool> visited(n, false);
Weight f = Dfs(s, INF, t, visited);
if (f <= 0) break;
flow += f;
}
return flow;
}
Weight Dfs(int v, Weight f, const int t, std::vector<bool> &visited) {
if (v == t) return f;
visited[v] = true;
for (auto &&e : adj[v]) {
if (!visited[e.dst] && 0 < e.cap) {
Weight d = Dfs(e.dst, std::min(f, e.cap), t, visited);
if (0 < d) {
e.cap -= d;
adj[e.dst][e.rev].cap += d;
return d;
}
}
}
return 0;
}
};
int main() {
cin.tie(0); ios::sync_with_stdio(false);
int N;
cin >> N;
vector<int> w(N);
for (auto &w_i : w) cin >> w_i;
const int s = 0, t = 2 * N + 1;
FordFulkerson<int> g(2 * N + 2);
for (int v = 1; v <= N; ++v) {
g.add_arc(s, v, 1);
g.add_arc(v + N, t, 1);
for (int u = v + 1; u <= N; ++u) {
if (w[v - 1] >= w[u - 1])
g.add_arc(v, u + N, 1);
}
}
cout << N - g.MaximumFlow(s, t) << endl;
return 0;
}