// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;
    vector<ll> A(N), B(N), M(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
        B[i] = A[i];
        if(i > 0) B[i] += B[i-1];
        if(i == 0) M[i] = max(0LL, A[i]);
        else M[i] = max(M[i-1], B[i]);
    }

    ll pos = 0, ma = 0;
    for(int i=0; i<N; i++) {
        chmax(ma, pos+M[i]);
        pos += B[i];
    }
    cout << ma << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF ((1LL<<62)-(1LL<<31))
typedef long long ll;

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int calc(int i) {
    int sum;
    sum=(3+i-2)*(i+3-1)/2;
    return sum;
} 

int main()
{
    int k;
    cin >> k;
    vector<int> dp(200020);
    dp[0]=0;
    dp[1]=1;
    for(int i=2;i<=k;i++) {
        ll tot=1,cnt=0;
        const auto &res = prime_factorize(i);
        for(auto x:res) {
            tot*=calc(x.second);
        }
        //cout << i << " " << tot+cnt << endl;
        dp[i]=dp[i-1]+tot+cnt;
    }
    cout << dp[k] << endl;
    return 0;
}