#include using namespace std; using ll=long long; #define rep2(i, a, n) for(int i = (a); i < (n); i++) #define rep(i, n) rep2(i,0,n) template inline bool chmax(T& a, T b){if(a>n; int p[n],a[n]; rep(i,n)cin>>p[i]>>a[i]; vector> dp(n+1,vector(2,-1)); dp[0][0]=0; rep(i,n){ rep(j,2){ if(dp[i][j]==-1)continue; if(j==0){ chmax(dp[i+1][0],dp[i][j]+p[i]); chmax(dp[i+1][1],dp[i][j]+a[i]); }else{ chmax(dp[i+1][0],dp[i][j]+p[i]+p[i]); chmax(dp[i+1][1],dp[i][j]+a[i]+a[i]); } } } cout<