#include<bits/stdc++.h> using namespace std; int n,a,b,t1,t2=110; int main(){ cin>>n; while(n--)cin>>a>>b,t1+=a,t2=min(t2,b); cout<<t1+t2; return 0; }