#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  cin >> n;
  vector<ll> a(n);
  for(int i = 0;i < n;i++)cin >> a[i];
  vector<ll> c;
  c.push_back(a[0]);
  for(int i = 1;i < n;i++){
    //if(i == 5)cout << c.size()<< " " << c[0] << " " << c[1] << " " << c[2] << endl;
    
    ll pushnum = 0;
    ll popit = lower_bound(c.begin(),c.end(),a[i]) - c.begin();
    if(popit == 0)pushnum = a[i];
    else{
      pushnum = a[i];
      c.erase(c.begin() + popit - 1);
    }
    
    ll pushit = lower_bound(c.begin(),c.end(),pushnum) - c.begin();
    c.insert(c.begin() + pushit,pushnum);
  }
  //cout << c[0] << " " << c[1] << " " << c[2] << endl;
  cout << c.size() << endl;
}
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<stack>
#include<iostream>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define MOD 1000000007
#define vec(a) vector<int>a
using namespace std;

bool isPrime(ll n)
{
	if(n==1||n==2||n==3||n==5||n==7)
		return 1;
	else
	{
		ll i,j,k,l,m;
		for(i=2;i<=sqrt(n);i++)
		{
			if(n%i==0)
				return 0;
		}
		return 1;
	}
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
	ll arr[3];
	cin>>arr[0]>>arr[1]>>arr[2];
	sort(arr,arr+3);
	cout<<arr[0]+arr[1];
	return 0;
}
	