#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 3;
const int maxval = 1e9 + 3;
const long long inf = 1e18;
struct rect {
  long long x, y, a;
  bool operator<(const rect &t) const { return x < t.x; }
};
long long get_val(pair<long long, long long> f, int x) {
  return f.first * x + f.second;
}
struct node {
  pair<long long, long long> f;
  node *left, *right;
  node() {
    left = right = nullptr;
    f = {0, -inf};
  }
};
void update(node *x, int l, int r, pair<long long, long long> f) {
  if (get_val(f, l) >= get_val(x->f, l) && get_val(f, r) >= get_val(x->f, r)) {
    x->f = f;
    return;
  }
  if (get_val(f, l) <= get_val(x->f, l) && get_val(f, r) <= get_val(x->f, r))
    return;
  if (l == r) return;
  if (!x->left) x->left = new node();
  if (!x->right) x->right = new node();
  int mid = (l + r) / 2;
  update(x->left, l, mid, f);
  update(x->right, mid + 1, r, f);
}
long long get(node *x, int l, int r, int pos) {
  if (!x) return -inf;
  if (l == r) return get_val(x->f, pos);
  int mid = (l + r) / 2;
  if (pos <= mid)
    return max(get_val(x->f, pos), get(x->left, l, mid, pos));
  else
    return max(get_val(x->f, pos), get(x->right, mid + 1, r, pos));
}
int n;
rect rects[maxn];
void read() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> rects[i].x >> rects[i].y >> rects[i].a;
}
node *tr = new node();
long long dp[maxn];
void solve() {
  sort(rects + 1, rects + n + 1);
  dp[1] = rects[1].x * rects[1].y - rects[1].a;
  update(tr, 1, maxval, {-rects[1].x, dp[1]});
  for (int i = 2; i <= n; i++) {
    dp[i] = rects[i].x * rects[i].y - rects[i].a +
            max(0ll, get(tr, 1, maxval, rects[i].y));
    update(tr, 1, maxval, {-rects[i].x, dp[i]});
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) ans = max(ans, dp[i]);
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  read();
  solve();
}
