#include <bits/stdc++.h>
#pragma optimize "O3"
#pragma optimize "fast-math"
using namespace std;
#define int long long
using ll = long long;
using vint = vector<int>;
using pii = pair<int, int>;
const int INF = 1 << 30;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    int ans = -LLONG_MAX;
    vector<pii> v;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        v.emplace_back(a, b);
    }
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            int now = 0;
            for (int j = 0; j < n; j++) {
                if (j > k) {
                    break;
                }
                now += v[j].first;
                if (j >= i) {
                    now += v[j].second * j;
                }
            }
            ans = max(ans, now);
        }
    }
    cout << ans;
}

//
//5 10
//3 1 1 2 2
