#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <numeric>

void Solve() {
    int n;
    std::cin >> n;
    std::vector<std::pair<long long, long long>> vec(n);

    for (int i = 0; i < n; ++i) {
        std::cin >> vec[i].first >> vec[i].second;
    }

    // std::vector<int> p(n);
    // for (int i = 0; i < n; ++i) {
    //     std::cin >> p[i];
    // }

    long long max = -6e18;
    std::vector<std::vector<long long>> dp(n, std::vector<long long>(n, -1e17));
    dp[0][0] = vec[0].first;
    
    for (int i = 1; i < n; ++i) {
        long long best_prev = -1e17;
        for (long long j = 0; j <= i; ++j) {
            best_prev = std::max(best_prev, dp[i - 1][j]);

            dp[i][j] = vec[i].first + vec[i].second * j + best_prev;
        }
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            max = std::max(dp[i][j], max);
        }
    }
    std::cout << max << '\n';
}

int main() {
    #ifdef LOCAL
    #else
        std::ios_base::sync_with_stdio(false);
        std::cin.tie(nullptr);
    #endif

    int t = 1;
    //std::cin >> t;

    for (int i = 0; i < t; ++i) {
        Solve();
    }
}