#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
  int N;
  cin>>N;

  vector<ll>A(N+1,0);
  for (int i=1;i<A.size();i++)
    cin>>A.at(i);

  vector<ll>p(N+1,0);
  vector<ll>q(N+1,0);
  for (int i=0;i<A.size()-1;i++){
    p.at(i+1)=p.at(i)+A.at(i+1);
    q.at(i+1)=q.at(i)>p.at(i+1)?q.at(i):p.at(i+1);
  }

  ll x=p.at(0);
  ll ans=q.at(0);
  for (int i=1;i<A.size();i++){
    ans=ans>x+q.at(i)?ans:x+q.at(i);
    x+=p.at(i);
  }

  cout<<ans<<endl;
  
  return 0;
}

/*
 *author:DJ
 *CODE GIVEN ABOVE ;)
 */
#pragma GCC optimize "trapv"
#pragma GCC optimize("O3") 
#include <bits/stdc++.h>
#define sq(a) a*a
const double pi = 2 * acos(0.0) ;
using namespace std ;
using ll = long long ;
template<typename... T>
void read(T&... args){
    ((cin >> args),...) ;
}


int main(){
#ifdef LOCAL
    freopen("in1","r",stdin) ;
#endif
    ios::sync_with_stdio(0) ; 
    cin.tie(nullptr) ;
    int a,b,c ; read(a,b,c) ; 
    cout << a + (c-b) << "\n" ;
    
#ifdef LOCAL
    cerr <<"The time elapsed is: " << 1.0 * clock()/CLOCKS_PER_SEC << "s.\n" ;
#endif
	return 0 ;
}

