#include<bits/stdc++.h>

#define Bye return 0
#define ll long long

using namespace std;

void solve(){
    int n; cin>>n;
    int a[n];
    for (int i=0; i<n; i++) cin>>a[i];

    int next = a[0];
    int cont = 1;
    for (int i=1; i<n; i++){
        if(a[i]<=next){
            next = a[i];
            cont++;
        }
    }
    cout<<cont<<endl;
}

int main(){
    solve();
    Bye;
}
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		A[i] *= -1;
	}
	vector<int> seq(N, 1 << 30);
	for (int i = 0; i < N; ++i) {
		*lower_bound(seq.begin(), seq.end(), A[i] + 1) = A[i];
	}
	cout << lower_bound(seq.begin(), seq.end(), 1 << 30) - seq.begin() << endl;
	return 0;
}