#include <bits/stdc++.h>
using namespace std;
const long long inf = 1ll << 60;
long long mode;
struct point {
  mutable long long a, b, k;
  bool operator<(const point &p) const { return mode ? k < p.k : a < p.a; }
};
struct hull {
  multiset<point> s;
  long long div(long long x, long long y) {
    return x / y - ((x ^ y) < 0 && x % y);
  }
  template <class T>
  bool test(T x, T y) {
    if (y == s.end()) {
      x->k = inf;
      return 0;
    }
    if (x->a == y->a)
      x->k = (x->b >= y->b ? inf : -inf);
    else
      x->k = div(x->b - y->b, y->a - x->a);
    return x->k >= y->k;
  }
  void add(long long a, long long b) {
    auto z = s.insert({a, b, 0}), x = z++, y = x;
    while (test(x, z)) z = s.erase(z);
    while ((y = x) != s.begin() && test(--x, y)) test(x, s.erase(y));
  }
  long long query(long long x) {
    mode = 1;
    auto pos = s.lower_bound({0, 0, x});
    mode = 0;
    return pos->a * x + pos->b;
  }
} cht;
const long long sz = 1e6 + 4;
pair<pair<long long, long long>, long long> a[sz];
void solve() {
  long long n;
  cin >> n;
  for (long long i = 0; i < n; ++i) {
    cin >> a[i].first.first >> a[i].first.second >> a[i].second;
  }
  sort(a, a + n);
  cht.add(0, 0);
  long long ans = 0;
  for (long long i = 0; i < n; ++i) {
    long long curr = cht.query(a[i].first.second);
    curr += a[i].first.first * a[i].first.second - a[i].second;
    ans = max(ans, curr);
    cht.add(-a[i].first.first, curr);
  }
  cout << ans << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
