#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

typedef long long ll;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N), S(N + 1, 0), M(N + 1, 0);
    rep(i, N) cin >> A[i];
    rep(i, N) {
        S[i + 1] = S[i] + A[i];
        M[i + 1] = max(M[i], S[i + 1]);
        //cout << S[i] << " " << M[i] << "\n";
    }
    ll ans = 0, x = 0;
    rep(i, N) {
        ans = max({ans, x + M[i + 1], x + S[i + 1]});
        x += S[i + 1];
    }
    cout << ans << "\n";
    //rep(i, N + 1) cout << S[i] << " " << M[i] << "\n";
}
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i:x){cout << i << " ";} cout << endl;}
#define isin(x,l,r) ((l)<=(x) && (x)<(r))
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using tii = tuple<int,int,int>;
template<typename T>bool chmin(T&x,const T&y) {if(x>y){x=y;return 1;} else return 0;}
template<typename T>bool chmax(T&x,const T&y) {if(x<y){x=y;return 1;} else return 0;}

int main() {
    ll K;
    cin >> K;
    if (K == 1) {
        cout << 1 << '\n';
        return 0;
    }
    ll ans = 0;
    // 全て違う数
    for (int i = 1; i <= K; i++) {
        for (int j = i+1; j <= K; j++) {
            if ((ll)i * j * (j+1) > K) break;
            int left = j+1;
            int right = K / (i*j);
            ans += (right - left + 1) * 6;
        }
    }
    // 2つ同じ数
    for (int i = 1; i <= K; i++) {
        if ((ll)i * i > K) break;
        int right = K / (i * i);
        int temp = right;
        if (right >= i) temp--; // iと重複
        ans += temp * 3;
    }
    // 全て同じ数
    for (int i = 1; i <= K; i++) {
        if ((ll)i * i * i > K) break;
        ans++;
    }
    cout << ans << '\n';
    return 0;
    // get dp together, ll, paraphrase, debug
}