#include<bits/stdc++.h> using namespace std; int n,ans,a,b,lb=0x3f3f3f3f; int main(){ cin>>n; while(n--){ cin>>a>>b; ans+=a; if(b<lb) lb=b; } cout<<ans+lb; return 0; }