#include <bits/stdc++.h>

using namespace std;

const int maxn = static_cast<const int>(5e5 + 10);
int n, r[maxn];
long long tree[maxn], f[maxn];
struct node
{
    long long a, b;
}a[maxn];

int lb(int x)
{
    return x & (-x);
}

long long read(int x)
{
    long long tot = 0;
    for (int i = x; i; i -= lb(i))
        tot += tree[i];
    return tot;
}

void add(long long num, int x)
{
    for (int i = x; i <= n; i += lb(i))
        tree[i] += num;
}

bool cmp(struct node x, struct node y)
{
    return x.a > y.a;
}

int main()
{
    ios::sync_with_stdio(false);
    cout.tie(0);
    cout.tie(0);

    while (cin >> n)
    {
        memset(tree, 0, sizeof(tree));
        long long ans = 0;
        for (int i = 1; i <= n; i++)
        {
            cin >> a[i].a;
            a[i].b = read(n) - read(a[i].a);
            ans += a[i].b;
            add(1, a[i].a);
        }
        sort(a+1, a+1+n,cmp);
        int pos;
        for(pos = 1; pos<=n; ++pos)
            if(a[pos].b!=0)
                break;
        cout << n-pos+1<<endl;
    }
    return 0;
}