#include <iostream>
#include <vector>
#include <set>
using namespace std;
using ll = long long;

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

	int N;
	cin >> N;
	set<int> s{};
	for (int i = 0; i <= 200000; i++) {
		s.insert(s.end(), i);
	}
	for (int i = 0; i < N; i++) {
		int p;
		cin >> p;
		if (s.find(p) != s.end()) {
			s.erase(p);
		}
		cout << *s.begin() << "\n";
	}

	return 0;
}

#include<fstream>
#include<iostream>
#include<sstream>
#include<vector>
#include<stack>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<queue>
#include<tuple>
#include<iomanip>
#include<stdio.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using graph = vector<vector<int>>;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
using ll = long long;
using P = pair<int, int>;


int main(){
  int n;
  cin >> n;
  vector<pair<int,int>> a;
  vector<pair<int,int>> b;
  vector<int> z;

  rep(i,n){
    int c,d;
      cin >> c >> d;
      int f = c+d;
      a.push_back(make_pair(c,i));
      b.push_back(make_pair(d,i));
      z.push_back(f);
    }

sort(a.begin(),a.end());
sort(b.begin(),b.end());
sort(z.begin(),z.end());

int ans = 0;

if(a[0].second!=b[0].second) cout << max(a[0].first,b[0].first) << endl;
else{
  int p = max(a[1].first,b[0].first);
  int q = max(a[0].first,b[1].first);
  int r = min(p,q);
  ans = min(z[0],r);
  cout << ans << endl;
}


}
