#include <bits/stdc++.h>
#define int long long
using namespace std;
using ii = pair<int, int>;

struct line {
    int a, b;
    mutable int x;  // x-intersect with the next line in the hull
    bool operator<(const line& other) const { return a < other.a; }
    bool operator<(const int& other_x) const { return x < other_x; }
};

class convex_hull : private multiset<line, less<>> {
    static const int inf = 1e18;

   public:
    int div(int a, int b) {  // floored division
        return a / b - ((a * b) < 0 && a % b);
    }
    // (for doubles, use inf = 1/.0, div(a,b) = a/b)

    bool overtake(iterator l1, iterator l2) {
        if (l2 == end()) return l1->x = inf, false;
        // if l2 is NULL, set l1->x and return immediately

        if (l1->a == l2->a) l1->x = l1->b > l2->b ? inf : -inf;
        // if the two line share the same slope, simply retain the one with the
        // higher y-intercept
        else
            l1->x = div(l2->b - l1->b, l1->a - l2->a);
        // x-intersect satisfies (l1->a)*x + l1->b = (l2->a)*x + l2->b
        return l1->x >= l2->x;
    }

    void add(int a, int b) {
        auto C = insert({a, b, 0}), N = C, P = C;

        overtake(C, ++N);  // calculating the x-intersect of C and N

        if (C != begin()) {
            int backup_p = (--P)->x;
            if (overtake(P, C)) {  // calculating the x-intersect of C and P
                erase(C);
                P->x = backup_p;
                return;
            }
        }

        while (overtake(C, N))
            N = erase(N);

        while (1) {
            C = P;
            if (C == begin()) break;
            P--;
            if (P->x < C->x) break;
            overtake(P, erase(C));
            // Since every invalid lines after and including C have been
            // removed, erase(C) is actually the originally added line, and we
            // recompute line P's p-index using that exact line.
        }
    }

    int query(int x) {
        if (empty()) return -inf;
        auto l = lower_bound(x);
        return l->a * x + l->b;
    }
} st;

int32_t main() {
    cin.tie(0)->sync_with_stdio(0);
    int n;
    cin >> n;
    vector<ii> a(n);

    for (int i = 0; i < n; i++)
        cin >> a[i].first >> a[i].second;

    sort(a.begin(), a.end());

    vector<ii> tmp;

    for (const auto& [h, w] : a) {
        while (tmp.size() && w >= tmp.back().second)
            tmp.pop_back();
        tmp.emplace_back(h, w);
    }

    a.swap(tmp);

    int p = 0, res = 0;
    for (const auto& [h, w] : a) {
        st.add(-w, -p);
        int c = -st.query(h);
        res = c;
        p = c;
    }

    return cout << res, 0;
}
