#include <bits/stdc++.h>

using namespace std;

#define fto(i, s, e) for (int i = (s); i <= (e); ++i)
#define fto1(i, s, e) for (int i = (s); i < (e); ++i)
#define fdto(i, s, e) for (int i = (s); i >= (e); --i)
#define fit(var, it) for (auto it = (var).begin(); it != (var).end(); ++it)
#define frit(var, it) for (auto it = (var).rbegin(); it != (var).rend(); ++it)

#define endl '\n'
#define bug1(x, i) cout << #x << '[' << i << "] = " << x[i] << endl
#define bug2(x, i, j) cout << #x << '[' << i << "][" << j << "] = " << x[i][j] << endl
#define bug3(x, i, j, k) cout << #x << '[' << i << "][" << j << "][" << k << "] = " << x[i][j][k] << endl

#define bc __builtin_popcountll
#define onb(x, bit) (x & (1 << bit))
#define gcd __gcd
#define y1 ansdj

#define ll long long
#define ii pair<int, int>
#define x first
#define y second
#define pb push_back
#define sz(v) int((v).size())

template<class T1, class T2> ostream& operator<< (ostream &os, pair<T1, T2> const &v) {
	return os << '(' << v.x << ", " << v.y << ')';
}

char __c;
template<class T> bool scan(T &val) {
    for (__c = getchar(); __c != '-' && __c != EOF && (__c < '0' || __c > '9'); __c = getchar()); if (__c == EOF) return 0;
    bool neg = (__c == '-'); if (neg) val = 0; else val = __c - '0';
    for (__c = getchar(); __c >= '0' && __c <= '9'; __c = getchar()) val = val*10 + __c - '0';
    if (neg) val = -val; return 1;
}
bool scan(char &c) { c = getchar(); return c != EOF; }
bool scan(string &s) {
	s = ""; for (__c = getchar(); __c == ' ' || __c == '\n'; __c = getchar()); if (__c == EOF) return 0;
	s += __c; for (__c = getchar(); __c != ' ' && __c != '\n' && __c != EOF; __c = getchar()) s += __c; return 1;
}
template<class T, class... Args> bool scan(T &val, Args&... args) { scan(val); return scan(args...); }

double const pi = acos(-1);
#define oo 1000000007
#define OO 1000000000000000003LL
#define maxn 1000003

struct data {
	pair<ll, ll> line;
	int lid, rid;
};

int n;
pair<pair<ll, ll>, ll> a[maxn];
vector<data> node;

ll get(pair<ll, ll> &line, ll x) {
	return line.x*x + line.y;
}

void extend(int root, int l, int r) {
	if (node[root].lid > -1) return;
	node[root].lid = sz(node); node.pb({{0, 0}, -1, -1});
	node[root].rid = sz(node); node.pb({{0, 0}, -1, -1});
}

ll query(int root, int l, int r, ll pos) {
	if (l > pos || r < pos) return -OO;
	ll res = get(node[root].line, pos);
	if (l == r) return res;
	int mid = (l+r)/2;
	extend(root, l, r);
	return max(res, max(query(node[root].lid, l, mid, pos), query(node[root].rid, mid+1, r, pos)));
}

void update(int root, int l, int r, pair<ll, ll> &line) {
	ll lval = get(node[root].line, l), lline = get(line, l);
	ll rval = get(node[root].line, r), rline = get(line, r);
	if (lval >= lline && rval >= rline) return;
	if (lval <= lline && rval <= rline) {
		node[root].line = line;
		return;
	}
	int mid = (l+r)/2;
	extend(root, l, r);
	ll mval = get(node[root].line, mid), mline = get(line, mid);
	if (lval >= lline && mval >= mline) {
		update(node[root].rid, mid+1, r, line);
		return;
	}
	if (lval <= lline && mval <= mline) {
		update(node[root].rid, mid+1, r, line);
		node[root].line = line;
		return;
	}
	mval = get(node[root].line, mid+1); mline = get(line, mid+1);
	if (mval >= mline && rval >= rline) {
		update(node[root].lid, l, mid, line);
		return;
	}
	if (mval <= mline && rval <= rline) {
		update(node[root].lid, l, mid, line);
		node[root].line = line;
		return;
	}
	update(node[root].lid, l, mid, line);
	update(node[root].rid, mid+1, r, line);
}

int main() {
	#ifdef KITTENS
		freopen("main.inp", "r", stdin);
		freopen("main.out", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	cin >> n;
	fto (i, 1, n) {
		cin >> a[i].x.x >> a[i].x.y >> a[i].y;
	}
	sort(a + 1, a + 1 + n);

	node.reserve(4*maxn);
	node.pb({{0, 0}, -1, -1});
	ll cur, ans = -OO;
	fto (i, 1, n) {
		cur = a[i].x.x * a[i].x.y - a[i].y + query(0, 1, 1e9, a[i].x.y);
		pair<ll, ll> line(-a[i].x.x, cur);
		update(0, 1, 1e9, line);
		ans = max(ans, cur);
	}

	cout << ans << endl;

	#ifdef KITTENS
		cerr << 0.001*clock() << endl;
	#endif
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fto(i, s, e) for (int i = (s); i <= (e); ++i)
#define fto1(i, s, e) for (int i = (s); i < (e); ++i)
#define fdto(i, s, e) for (int i = (s); i >= (e); --i)
#define fit(var, it) for (auto it = (var).begin(); it != (var).end(); ++it)
#define frit(var, it) for (auto it = (var).rbegin(); it != (var).rend(); ++it)

#define endl '\n'
#define bug1(x, i) cout << #x << '[' << i << "] = " << x[i] << endl
#define bug2(x, i, j) cout << #x << '[' << i << "][" << j << "] = " << x[i][j] << endl
#define bug3(x, i, j, k) cout << #x << '[' << i << "][" << j << "][" << k << "] = " << x[i][j][k] << endl

#define bc __builtin_popcountll
#define onb(x, bit) (x & (1 << bit))
#define gcd __gcd
#define y1 ansdj

#define ll long long
#define ii pair<int, int>
#define x first
#define y second
#define pb push_back
#define sz(v) int((v).size())

template<class T1, class T2> ostream& operator<< (ostream &os, pair<T1, T2> const &v) {
	return os << '(' << v.x << ", " << v.y << ')';
}

char __c;
template<class T> bool scan(T &val) {
    for (__c = getchar(); __c != '-' && __c != EOF && (__c < '0' || __c > '9'); __c = getchar()); if (__c == EOF) return 0;
    bool neg = (__c == '-'); if (neg) val = 0; else val = __c - '0';
    for (__c = getchar(); __c >= '0' && __c <= '9'; __c = getchar()) val = val*10 + __c - '0';
    if (neg) val = -val; return 1;
}
bool scan(char &c) { c = getchar(); return c != EOF; }
bool scan(string &s) {
	s = ""; for (__c = getchar(); __c == ' ' || __c == '\n'; __c = getchar()); if (__c == EOF) return 0;
	s += __c; for (__c = getchar(); __c != ' ' && __c != '\n' && __c != EOF; __c = getchar()) s += __c; return 1;
}
template<class T, class... Args> bool scan(T &val, Args&... args) { scan(val); return scan(args...); }

double const pi = acos(-1);
#define oo 1000000007
#define OO 1000000000000000003LL
#define maxn 1000003

struct data {
	pair<ll, ll> line;
	data *left, *right;
};

int n;
pair<pair<ll, int>, ll> a[maxn];
vector<int> s;

ll get(pair<ll, ll> &line, int x) {
	return -line.x*x + line.y;
}

void extend(data *root) {
	if (root->left) return;
	root->left = new data({{0ll, 0ll}, nullptr, nullptr});
	root->right = new data({{0ll, 0ll}, nullptr, nullptr});
}

ll query(data *root, int l, int r, int pos) {
	if (l > pos || r < pos) return -OO;
	ll res = get(root->line, s[pos]);
	if (l == r) return res;
	int mid = (l+r)/2;
	extend(root);
	return max(res, max(query(root->left, l, mid, pos), query(root->right, mid+1, r, pos)));
}

void update(data *root, int l, int r, pair<ll, ll> &line) {
	bool lval = get(root->line, s[l]) >= get(line, s[l]);
	bool rval = get(root->line, s[r]) >= get(line, s[r]);
	if (lval && rval) return;
	if (!lval && !rval) {
		root->line = line;
		return;
	}
	int mid = (l+r)/2;
	extend(root);
	bool mval = get(root->line, s[mid]) >= get(line, s[mid]);
	if (lval && mval) {
		update(root->right, mid+1, r, line);
		return;
	}
	if (!lval && !mval) {
		update(root->right, mid+1, r, root->line);
		root->line = line;
		return;
	}
	mval = get(root->line, s[mid+1]) >= get(line, s[mid+1]);
	if (mval && rval) {
		update(root->left, l, mid, line);
		return;
	}
	if (!mval && !rval) {
		update(root->left, l, mid, root->line);
		root->line = line;
		return;
	}
	update(root->left, l, mid, line);
	update(root->right, mid+1, r, line);
}

int main() {
	#ifdef KITTENS
		freopen("main.inp", "r", stdin);
		freopen("main.out", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	cin >> n;
	fto (i, 1, n) {
		cin >> a[i].x.x >> a[i].x.y >> a[i].y;
		s.pb(a[i].x.y);
	}
	sort(a + 1, a + 1 + n);
	sort(s.begin(), s.end());
	s.erase(unique(s.begin(), s.end()), s.end());
	data *root = new data({{0ll, 0ll}, nullptr, nullptr});

	ll cur, ans = 0;
	fto (i, 1, n) {
		int pos = lower_bound(s.begin(), s.end(), a[i].x.y) - s.begin();
		cur = a[i].x.x * a[i].x.y - a[i].y + query(root, 0, sz(s)-1, pos);
		pair<ll, ll> line(a[i].x.x, cur);
		update(root, 0, sz(s)-1, line);
		ans = max(ans, cur);
	}

	cout << ans << endl;

	#ifdef KITTENS
		cerr << 0.001*clock() << endl;
	#endif
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fto(i, s, e) for (int i = (s); i <= (e); ++i)
#define fto1(i, s, e) for (int i = (s); i < (e); ++i)
#define fdto(i, s, e) for (int i = (s); i >= (e); --i)
#define fit(var, it) for (auto it = (var).begin(); it != (var).end(); ++it)
#define frit(var, it) for (auto it = (var).rbegin(); it != (var).rend(); ++it)

#define endl '\n'
#define bug1(x, i) cout << #x << '[' << i << "] = " << x[i] << endl
#define bug2(x, i, j) cout << #x << '[' << i << "][" << j << "] = " << x[i][j] << endl
#define bug3(x, i, j, k) cout << #x << '[' << i << "][" << j << "][" << k << "] = " << x[i][j][k] << endl

#define bc __builtin_popcountll
#define onb(x, bit) (x & (1 << bit))
#define gcd __gcd
#define y1 ansdj

#define ll long long
#define ii pair<int, int>
#define x first
#define y second
#define pb push_back
#define sz(v) int((v).size())

template<class T1, class T2> ostream& operator<< (ostream &os, pair<T1, T2> const &v) {
	return os << '(' << v.x << ", " << v.y << ')';
}

char __c;
template<class T> bool scan(T &val) {
    for (__c = getchar(); __c != '-' && __c != EOF && (__c < '0' || __c > '9'); __c = getchar()); if (__c == EOF) return 0;
    bool neg = (__c == '-'); if (neg) val = 0; else val = __c - '0';
    for (__c = getchar(); __c >= '0' && __c <= '9'; __c = getchar()) val = val*10 + __c - '0';
    if (neg) val = -val; return 1;
}
bool scan(char &c) { c = getchar(); return c != EOF; }
bool scan(string &s) {
	s = ""; for (__c = getchar(); __c == ' ' || __c == '\n'; __c = getchar()); if (__c == EOF) return 0;
	s += __c; for (__c = getchar(); __c != ' ' && __c != '\n' && __c != EOF; __c = getchar()) s += __c; return 1;
}
template<class T, class... Args> bool scan(T &val, Args&... args) { scan(val); return scan(args...); }

double const pi = acos(-1);
#define oo 1000000007
#define OO 1000000000000000003LL
#define maxn 1000003

struct data {
	pair<ll, unsigned ll> line;
	int lid, rid;
};

int n;
pair<pair<ll, ll>, ll> a[maxn];
vector<data> node;

ll get(pair<ll, unsigned ll> &line, ll x) {
	return -line.x*x + line.y;
}

unsigned ll get2(pair<ll, unsigned ll> &line, ll x) {
	if (line.x*x > line.y) return 0;
	return line.y -line.x*x;
}

void extend(int root, int l, int r) {
	if (node[root].lid > -1) return;
	node[root].lid = sz(node); node.pb({{0, 0}, -1, -1});
	node[root].rid = sz(node); node.pb({{0, 0}, -1, -1});
}

ll query(int root, int l, int r, ll pos) {
	if (l > pos || r < pos) return -OO;
	ll res = get2(node[root].line, pos);
	if (l == r) return res;
	int mid = (l+r)/2;
	extend(root, l, r);
	return max(res, max(query(node[root].lid, l, mid, pos), query(node[root].rid, mid+1, r, pos)));
}

void update(int root, int l, int r, pair<ll, unsigned ll> line) {
	ll lval = get(node[root].line, l), lline = get(line, l);
	ll rval = get(node[root].line, r), rline = get(line, r);
	if (lval >= lline && rval >= rline) return;
	if (lval <= lline && rval <= rline) {
		node[root].line = line;
		return;
	}
	int mid = (l+r)/2;
	extend(root, l, r);
	ll mval = get(node[root].line, mid), mline = get(line, mid);
	if (lval >= lline && mval >= mline) {
		update(node[root].rid, mid+1, r, line);
		return;
	}
	if (lval <= lline && mval <= mline) {
		update(node[root].rid, mid+1, r, node[root].line);
		node[root].line = line;
		return;
	}
	mval = get(node[root].line, mid+1); mline = get(line, mid+1);
	if (mval >= mline && rval >= rline) {
		update(node[root].lid, l, mid, line);
		return;
	}
	if (mval <= mline && rval <= rline) {
		update(node[root].lid, l, mid, node[root].line);
		node[root].line = line;
		return;
	}
	update(node[root].lid, l, mid, line);
	update(node[root].rid, mid+1, r, line);
}

int main() {
	#ifdef KITTENS
		freopen("main.inp", "r", stdin);
		freopen("main.out", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	cin >> n;
	fto (i, 1, n) {
		cin >> a[i].x.x >> a[i].x.y >> a[i].y;
	}
	sort(a + 1, a + 1 + n);

	node.reserve(4*maxn);
	node.pb({{0, 0}, -1, -1});
	unsigned ll cur, ans = 0;
	fto (i, 1, n) {
		cur = a[i].x.x * a[i].x.y - a[i].y + query(0, 1, 1e9, a[i].x.y);
		pair<ll, unsigned ll> line(a[i].x.x, cur);
		update(0, 1, 1e9, line);
		ans = max(ans, cur);
	}

	cout << ans << endl;

	#ifdef KITTENS
		cerr << 0.001*clock() << endl;
	#endif
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fto(i, s, e) for (int i = (s); i <= (e); ++i)
#define fto1(i, s, e) for (int i = (s); i < (e); ++i)
#define fdto(i, s, e) for (int i = (s); i >= (e); --i)
#define fit(var, it) for (auto it = (var).begin(); it != (var).end(); ++it)
#define frit(var, it) for (auto it = (var).rbegin(); it != (var).rend(); ++it)

#define endl '\n'
#define bug1(x, i) cout << #x << '[' << i << "] = " << x[i] << endl
#define bug2(x, i, j) cout << #x << '[' << i << "][" << j << "] = " << x[i][j] << endl
#define bug3(x, i, j, k) cout << #x << '[' << i << "][" << j << "][" << k << "] = " << x[i][j][k] << endl

#define bc __builtin_popcountll
#define onb(x, bit) (x & (1 << bit))
#define gcd __gcd
#define y1 ansdj

#define ll long long
#define ii pair<int, int>
#define x first
#define y second
#define pb push_back
#define sz(v) int((v).size())

template<class T1, class T2> ostream& operator<< (ostream &os, pair<T1, T2> const &v) {
	return os << '(' << v.x << ", " << v.y << ')';
}

char __c;
template<class T> bool scan(T &val) {
    for (__c = getchar(); __c != '-' && __c != EOF && (__c < '0' || __c > '9'); __c = getchar()); if (__c == EOF) return 0;
    bool neg = (__c == '-'); if (neg) val = 0; else val = __c - '0';
    for (__c = getchar(); __c >= '0' && __c <= '9'; __c = getchar()) val = val*10 + __c - '0';
    if (neg) val = -val; return 1;
}
bool scan(char &c) { c = getchar(); return c != EOF; }
bool scan(string &s) {
	s = ""; for (__c = getchar(); __c == ' ' || __c == '\n'; __c = getchar()); if (__c == EOF) return 0;
	s += __c; for (__c = getchar(); __c != ' ' && __c != '\n' && __c != EOF; __c = getchar()) s += __c; return 1;
}
template<class T, class... Args> bool scan(T &val, Args&... args) { scan(val); return scan(args...); }

double const pi = acos(-1);
#define oo 1000000007
#define OO 1000000000000000003LL
#define maxn 1000003

struct data {
	pair<ll, ll> line;
	data *left, *right;
};

int n;
pair<pair<ll, ll>, ll> a[maxn];

ll get(pair<ll, ll> &line, ll x) {
	return -line.x*x + line.y;
}

void extend(data *root) {
	if (root->left) return;
	root->left = new data({{0ll, 0ll}, nullptr, nullptr});
	root->right = new data({{0ll, 0ll}, nullptr, nullptr});
}

ll query(data *root, int l, int r, ll pos) {
	if (l > pos || r < pos) return -OO;
	ll res = get(root->line, pos);
	if (l == r) return res;
	int mid = (l+r)/2;
	extend(root);
	return max(res, max(query(root->left, l, mid, pos), query(root->right, mid+1, r, pos)));
}

void update(data *root, int l, int r, pair<ll, ll> &line) {
	bool lval = get(root->line, l) >= get(line, l);
	bool rval = get(root->line, r) >= get(line, r);
	if (lval && rval) return;
	if (!lval && !rval) {
		root->line = line;
		return;
	}
	int mid = (l+r)/2;
	extend(root);
	bool mval = get(root->line, mid) >= get(line, mid);
	if (lval && mval) {
		update(root->right, mid+1, r, line);
		return;
	}
	if (!lval && !mval) {
		update(root->right, mid+1, r, root->line);
		root->line = line;
		return;
	}
	mval = get(root->line, mid+1) >= get(line, mid+1);
	if (mval && rval) {
		update(root->left, l, mid, line);
		return;
	}
	if (!mval && !rval) {
		update(root->left, l, mid, root->line);
		root->line = line;
		return;
	}
	update(root->left, l, mid, line);
	update(root->right, mid+1, r, line);
}

int main() {
	#ifdef KITTENS
		freopen("main.inp", "r", stdin);
		freopen("main.out", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	cin >> n;
	fto (i, 1, n) {
		cin >> a[i].x.x >> a[i].x.y >> a[i].y;
	}
	sort(a + 1, a + 1 + n);
	data *root = new data({{0ll, 0ll}, nullptr, nullptr});

	ll cur, ans = 0;
	fto (i, 1, n) {
		cur = a[i].x.x * a[i].x.y - a[i].y + query(root, 1, 1e9, a[i].x.y);
		pair<ll, ll> line(a[i].x.x, cur);
		update(root, 1, 1e9, line);
		ans = max(ans, cur);
	}

	cout << ans << endl;

	#ifdef KITTENS
		cerr << 0.001*clock() << endl;
	#endif
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fto(i, s, e) for (int i = (s); i <= (e); ++i)
#define fto1(i, s, e) for (int i = (s); i < (e); ++i)
#define fdto(i, s, e) for (int i = (s); i >= (e); --i)
#define fit(var, it) for (auto it = (var).begin(); it != (var).end(); ++it)
#define frit(var, it) for (auto it = (var).rbegin(); it != (var).rend(); ++it)

#define endl '\n'
#define bug1(x, i) cout << #x << '[' << i << "] = " << x[i] << endl
#define bug2(x, i, j) cout << #x << '[' << i << "][" << j << "] = " << x[i][j] << endl
#define bug3(x, i, j, k) cout << #x << '[' << i << "][" << j << "][" << k << "] = " << x[i][j][k] << endl

#define bc __builtin_popcountll
#define onb(x, bit) (x & (1 << bit))
#define gcd __gcd
#define y1 ansdj

#define ll long long
#define ii pair<int, int>
#define x first
#define y second
#define pb push_back
#define sz(v) int((v).size())

template<class T1, class T2> ostream& operator<< (ostream &os, pair<T1, T2> const &v) {
	return os << '(' << v.x << ", " << v.y << ')';
}

char __c;
template<class T> bool scan(T &val) {
    for (__c = getchar(); __c != '-' && __c != EOF && (__c < '0' || __c > '9'); __c = getchar()); if (__c == EOF) return 0;
    bool neg = (__c == '-'); if (neg) val = 0; else val = __c - '0';
    for (__c = getchar(); __c >= '0' && __c <= '9'; __c = getchar()) val = val*10 + __c - '0';
    if (neg) val = -val; return 1;
}
bool scan(char &c) { c = getchar(); return c != EOF; }
bool scan(string &s) {
	s = ""; for (__c = getchar(); __c == ' ' || __c == '\n'; __c = getchar()); if (__c == EOF) return 0;
	s += __c; for (__c = getchar(); __c != ' ' && __c != '\n' && __c != EOF; __c = getchar()) s += __c; return 1;
}
template<class T, class... Args> bool scan(T &val, Args&... args) { scan(val); return scan(args...); }

double const pi = acos(-1);
#define oo 1000000007
#define OO 1000000000000000003LL
#define maxn 1000003

struct data {
	pair<ll, ll> line;
	int lid, rid;
};

int n;
pair<pair<ll, ll>, ll> a[maxn];
vector<data> node;

ll get(pair<ll, ll> &line, ll x) {
	return line.x*x + line.y;
}

void extend(int root, int l, int r) {
	if (node[root].lid > -1) return;
	node[root].lid = sz(node); node.pb({{0, 0}, -1, -1});
	node[root].rid = sz(node); node.pb({{0, 0}, -1, -1});
}

ll query(int root, int l, int r, ll pos) {
	if (l > pos || r < pos) return -OO;
	ll res = get(node[root].line, pos);
	if (l == r) return res;
	int mid = (l+r)/2;
	extend(root, l, r);
	return max(res, max(query(node[root].lid, l, mid, pos), query(node[root].rid, mid+1, r, pos)));
}

void update(int root, int l, int r, pair<ll, ll> &line) {
	ll lval = get(node[root].line, l), lline = get(line, l);
	ll rval = get(node[root].line, r), rline = get(line, r);
	if (lval >= lline && rval >= rline) return;
	if (lval <= lline && rval <= rline) {
		node[root].line = line;
		return;
	}
	int mid = (l+r)/2;
	extend(root, l, r);
	ll mval = get(node[root].line, mid), mline = get(line, mid);
	if (lval >= lline && mval >= mline) {
		update(node[root].rid, mid+1, r, line);
		return;
	}
	if (lval <= lline && mval <= mline) {
		update(node[root].rid, mid+1, r, line);
		node[root].line = line;
		return;
	}
	mval = get(node[root].line, mid+1); mline = get(line, mid+1);
	if (mval >= mline && rval >= rline) {
		update(node[root].lid, l, mid, line);
		return;
	}
	if (mval <= mline && rval <= rline) {
		update(node[root].lid, l, mid, line);
		node[root].line = line;
		return;
	}
	update(node[root].lid, l, mid, line);
	update(node[root].rid, mid+1, r, line);
}

int main() {
	#ifdef KITTENS
		freopen("main.inp", "r", stdin);
		freopen("main.out", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	scan(n);
	fto (i, 1, n) {
		scan(a[i].x.x, a[i].x.y, a[i].y);
	}
	sort(a + 1, a + 1 + n);

	node.reserve(4*maxn);
	node.pb({{0, 0}, -1, -1});
	ll cur, ans = -OO;
	fto (i, 1, n) {
		cur = a[i].x.x * a[i].x.y - a[i].y + query(0, 1, 1e9, a[i].x.y);
		pair<ll, ll> line(-a[i].x.x, cur);
		update(0, 1, 1e9, line);
		ans = max(ans, cur);
	}

	cout << ans << endl;

	#ifdef KITTENS
		cerr << 0.001*clock() << endl;
	#endif
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fto(i, s, e) for (int i = (s); i <= (e); ++i)
#define fto1(i, s, e) for (int i = (s); i < (e); ++i)
#define fdto(i, s, e) for (int i = (s); i >= (e); --i)
#define fit(var, it) for (auto it = (var).begin(); it != (var).end(); ++it)
#define frit(var, it) for (auto it = (var).rbegin(); it != (var).rend(); ++it)

#define endl '\n'
#define bug1(x, i) cout << #x << '[' << i << "] = " << x[i] << endl
#define bug2(x, i, j) cout << #x << '[' << i << "][" << j << "] = " << x[i][j] << endl
#define bug3(x, i, j, k) cout << #x << '[' << i << "][" << j << "][" << k << "] = " << x[i][j][k] << endl

#define bc __builtin_popcountll
#define onb(x, bit) (x & (1 << bit))
#define gcd __gcd
#define y1 ansdj

#define ll long long
#define ii pair<int, int>
#define x first
#define y second
#define pb push_back
#define sz(v) int((v).size())

template<class T1, class T2> ostream& operator<< (ostream &os, pair<T1, T2> const &v) {
	return os << '(' << v.x << ", " << v.y << ')';
}

char __c;
template<class T> bool scan(T &val) {
    for (__c = getchar(); __c != '-' && __c != EOF && (__c < '0' || __c > '9'); __c = getchar()); if (__c == EOF) return 0;
    bool neg = (__c == '-'); if (neg) val = 0; else val = __c - '0';
    for (__c = getchar(); __c >= '0' && __c <= '9'; __c = getchar()) val = val*10 + __c - '0';
    if (neg) val = -val; return 1;
}
bool scan(char &c) { c = getchar(); return c != EOF; }
bool scan(string &s) {
	s = ""; for (__c = getchar(); __c == ' ' || __c == '\n'; __c = getchar()); if (__c == EOF) return 0;
	s += __c; for (__c = getchar(); __c != ' ' && __c != '\n' && __c != EOF; __c = getchar()) s += __c; return 1;
}
template<class T, class... Args> bool scan(T &val, Args&... args) { scan(val); return scan(args...); }

double const pi = acos(-1);
#define oo 1000000007
#define OO 1000000000000000003LL
#define maxn 1000003

struct data {
	pair<ll, unsigned ll> line;
	int lid, rid;
};

int n;
pair<pair<ll, ll>, ll> a[maxn];
vector<data> node;

ll get(pair<ll, unsigned ll> &line, ll x) {
	return -line.x*x + line.y;
}

unsigned ll get2(pair<ll, unsigned ll> &line, ll x) {
	if (line.x*x > line.y) return 0;
	return line.y -line.x*x;
}

void extend(int root, int l, int r) {
	if (node[root].lid > -1) return;
	node[root].lid = sz(node); node.pb({{0, 0}, -1, -1});
	node[root].rid = sz(node); node.pb({{0, 0}, -1, -1});
}

ll query(int root, int l, int r, ll pos) {
	if (l > pos || r < pos) return -OO;
	ll res = get2(node[root].line, pos);
	if (l == r) return res;
	int mid = (l+r)/2;
	extend(root, l, r);
	return max(res, max(query(node[root].lid, l, mid, pos), query(node[root].rid, mid+1, r, pos)));
}

void update(int root, int l, int r, pair<ll, unsigned ll> &line) {
	ll lval = get(node[root].line, l), lline = get(line, l);
	ll rval = get(node[root].line, r), rline = get(line, r);
	if (lval >= lline && rval >= rline) return;
	if (lval <= lline && rval <= rline) {
		node[root].line = line;
		return;
	}
	int mid = (l+r)/2;
	extend(root, l, r);
	ll mval = get(node[root].line, mid), mline = get(line, mid);
	if (lval >= lline && mval >= mline) {
		update(node[root].rid, mid+1, r, line);
		return;
	}
	if (lval <= lline && mval <= mline) {
		update(node[root].rid, mid+1, r, line);
		node[root].line = line;
		return;
	}
	mval = get(node[root].line, mid+1); mline = get(line, mid+1);
	if (mval >= mline && rval >= rline) {
		update(node[root].lid, l, mid, line);
		return;
	}
	if (mval <= mline && rval <= rline) {
		update(node[root].lid, l, mid, line);
		node[root].line = line;
		return;
	}
	update(node[root].lid, l, mid, line);
	update(node[root].rid, mid+1, r, line);
}

int main() {
	#ifdef KITTENS
		freopen("main.inp", "r", stdin);
		freopen("main.out", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	cin >> n;
	fto (i, 1, n) {
		cin >> a[i].x.x >> a[i].x.y >> a[i].y;
	}
	sort(a + 1, a + 1 + n);

	node.reserve(4*maxn);
	node.pb({{0, 0}, -1, -1});
	unsigned ll cur, ans = 0;
	fto (i, 1, n) {
		cur = a[i].x.x * a[i].x.y - a[i].y + query(0, 1, 1e9, a[i].x.y);
		pair<ll, unsigned ll> line(a[i].x.x, cur);
		update(0, 1, 1e9, line);
		ans = max(ans, cur);
	}

	cout << ans << endl;

	#ifdef KITTENS
		cerr << 0.001*clock() << endl;
	#endif
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fto(i, s, e) for (int i = (s); i <= (e); ++i)
#define fto1(i, s, e) for (int i = (s); i < (e); ++i)
#define fdto(i, s, e) for (int i = (s); i >= (e); --i)
#define fit(var, it) for (auto it = (var).begin(); it != (var).end(); ++it)
#define frit(var, it) for (auto it = (var).rbegin(); it != (var).rend(); ++it)

#define endl '\n'
#define bug1(x, i) cout << #x << '[' << i << "] = " << x[i] << endl
#define bug2(x, i, j) cout << #x << '[' << i << "][" << j << "] = " << x[i][j] << endl
#define bug3(x, i, j, k) cout << #x << '[' << i << "][" << j << "][" << k << "] = " << x[i][j][k] << endl

#define bc __builtin_popcountll
#define onb(x, bit) (x & (1 << bit))
#define gcd __gcd
#define y1 ansdj

#define ll long long
#define ii pair<int, int>
#define x first
#define y second
#define pb push_back
#define sz(v) int((v).size())

template<class T1, class T2> ostream& operator<< (ostream &os, pair<T1, T2> const &v) {
	return os << '(' << v.x << ", " << v.y << ')';
}

char __c;
template<class T> bool scan(T &val) {
    for (__c = getchar(); __c != '-' && __c != EOF && (__c < '0' || __c > '9'); __c = getchar()); if (__c == EOF) return 0;
    bool neg = (__c == '-'); if (neg) val = 0; else val = __c - '0';
    for (__c = getchar(); __c >= '0' && __c <= '9'; __c = getchar()) val = val*10 + __c - '0';
    if (neg) val = -val; return 1;
}
bool scan(char &c) { c = getchar(); return c != EOF; }
bool scan(string &s) {
	s = ""; for (__c = getchar(); __c == ' ' || __c == '\n'; __c = getchar()); if (__c == EOF) return 0;
	s += __c; for (__c = getchar(); __c != ' ' && __c != '\n' && __c != EOF; __c = getchar()) s += __c; return 1;
}
template<class T, class... Args> bool scan(T &val, Args&... args) { scan(val); return scan(args...); }

double const pi = acos(-1);
#define oo 1000000007
#define OO 1000000000000000003LL
#define maxn 1000003

struct data {
	pair<ll, ll> line;
	data *left, *right;
};

int n;
pair<pair<ll, int>, ll> a[maxn];
vector<int> s;

ll get(pair<ll, ll> &line, int x) {
	return -line.x*x + line.y;
}

void extend(data *root) {
	if (root->left) return;
	root->left = new data({{0ll, 0ll}, nullptr, nullptr});
	root->right = new data({{0ll, 0ll}, nullptr, nullptr});
}

ll query(data *root, int l, int r, int pos) {
	if (l > pos || r < pos) return -OO;
	ll res = get(root->line, s[pos]);
	if (l == r) return res;
	int mid = (l+r)/2;
	extend(root);
	return max(res, max(query(root->left, l, mid, pos), query(root->right, mid+1, r, pos)));
}

void update(data *root, int l, int r, pair<ll, ll> &line) {
	bool lval = get(root->line, s[l]) >= get(line, s[l]);
	bool rval = get(root->line, s[r]) >= get(line, s[r]);
	if (lval && rval) return;
	if (!lval && !rval) {
		root->line = line;
		return;
	}
	int mid = (l+r)/2;
	extend(root);
	bool mval = get(root->line, s[mid]) >= get(line, s[mid]);
	if (lval && mval) {
		update(root->right, mid+1, r, line);
		return;
	}
	if (!lval && !mval) {
		update(root->right, mid+1, r, root->line);
		root->line = line;
		return;
	}
	mval = get(root->line, s[mid+1]) >= get(line, s[mid+1]);
	if (mval && rval) {
		update(root->left, l, mid, line);
		return;
	}
	if (!mval && !rval) {
		update(root->left, l, mid, root->line);
		root->line = line;
		return;
	}
	update(root->left, l, mid, line);
	update(root->right, mid+1, r, line);
}

int main() {
	#ifdef KITTENS
		freopen("main.inp", "r", stdin);
		freopen("main.out", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	scanf("%d", &n);
	fto (i, 1, n) {
		scanf("%lld%d%lld", &a[i].x.x, &a[i].x.y, &a[i].y);
		s.pb(a[i].x.y);
	}
	sort(a + 1, a + 1 + n);
	sort(s.begin(), s.end());
	s.erase(unique(s.begin(), s.end()), s.end());
	data *root = new data({{0ll, 0ll}, nullptr, nullptr});

	ll cur, ans = 0;
	fto (i, 1, n) {
		int pos = lower_bound(s.begin(), s.end(), a[i].x.y) - s.begin();
		cur = a[i].x.x * a[i].x.y - a[i].y + query(root, 0, sz(s)-1, pos);
		pair<ll, ll> line(a[i].x.x, cur);
		update(root, 0, sz(s)-1, line);
		ans = max(ans, cur);
	}

	cout << ans << endl;

	#ifdef KITTENS
		cerr << 0.001*clock() << endl;
	#endif
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fto(i, s, e) for (int i = (s); i <= (e); ++i)
#define fto1(i, s, e) for (int i = (s); i < (e); ++i)
#define fdto(i, s, e) for (int i = (s); i >= (e); --i)
#define fit(var, it) for (auto it = (var).begin(); it != (var).end(); ++it)
#define frit(var, it) for (auto it = (var).rbegin(); it != (var).rend(); ++it)

#define endl '\n'
#define bug1(x, i) cout << #x << '[' << i << "] = " << x[i] << endl
#define bug2(x, i, j) cout << #x << '[' << i << "][" << j << "] = " << x[i][j] << endl
#define bug3(x, i, j, k) cout << #x << '[' << i << "][" << j << "][" << k << "] = " << x[i][j][k] << endl

#define bc __builtin_popcountll
#define onb(x, bit) (x & (1 << bit))
#define gcd __gcd
#define y1 ansdj

#define ll long long
#define ii pair<int, int>
#define x first
#define y second
#define pb push_back
#define sz(v) int((v).size())

template<class T1, class T2> ostream& operator<< (ostream &os, pair<T1, T2> const &v) {
	return os << '(' << v.x << ", " << v.y << ')';
}

char __c;
template<class T> bool scan(T &val) {
    for (__c = getchar(); __c != '-' && __c != EOF && (__c < '0' || __c > '9'); __c = getchar()); if (__c == EOF) return 0;
    bool neg = (__c == '-'); if (neg) val = 0; else val = __c - '0';
    for (__c = getchar(); __c >= '0' && __c <= '9'; __c = getchar()) val = val*10 + __c - '0';
    if (neg) val = -val; return 1;
}
bool scan(char &c) { c = getchar(); return c != EOF; }
bool scan(string &s) {
	s = ""; for (__c = getchar(); __c == ' ' || __c == '\n'; __c = getchar()); if (__c == EOF) return 0;
	s += __c; for (__c = getchar(); __c != ' ' && __c != '\n' && __c != EOF; __c = getchar()) s += __c; return 1;
}
template<class T, class... Args> bool scan(T &val, Args&... args) { scan(val); return scan(args...); }

double const pi = acos(-1);
#define oo 1000000007
#define OO 1000000000000000003LL
#define maxn 1000003

struct data {
	pair<ll, ll> line;
	data *left, *right;
};

int n;
pair<pair<ll, int>, ll> a[maxn];
vector<int> s;

ll get(pair<ll, ll> &line, int x) {
	return -line.x*x + line.y;
}

void extend(data *root) {
	if (root->left) return;
	root->left = new data({{0ll, 0ll}, nullptr, nullptr});
	root->right = new data({{0ll, 0ll}, nullptr, nullptr});
}

ll query(data *root, int l, int r, int pos) {
	if (l > pos || r < pos) return -OO;
	ll res = get(root->line, s[pos]);
	if (l == r) return res;
	int mid = (l+r)/2;
	extend(root);
	return max(res, max(query(root->left, l, mid, pos), query(root->right, mid+1, r, pos)));
}

void update(data *root, int l, int r, pair<ll, ll> &line) {
	bool lval = get(root->line, s[l]) >= get(line, s[l]);
	bool rval = get(root->line, s[r]) >= get(line, s[r]);
	if (lval && rval) return;
	if (!lval && !rval) {
		root->line = line;
		return;
	}
	int mid = (l+r)/2;
	extend(root);
	bool mval = get(root->line, s[mid]) >= get(line, s[mid]);
	if (lval && mval) {
		update(root->right, mid+1, r, line);
		return;
	}
	if (!lval && !mval) {
		update(root->right, mid+1, r, root->line);
		root->line = line;
		return;
	}
	mval = get(root->line, s[mid+1]) >= get(line, s[mid+1]);
	if (mval && rval) {
		update(root->left, l, mid, line);
		return;
	}
	if (!mval && !rval) {
		update(root->left, l, mid, root->line);
		root->line = line;
		return;
	}
	update(root->left, l, mid, line);
	update(root->right, mid+1, r, line);
}

int main() {
	#ifdef KITTENS
		freopen("main.inp", "r", stdin);
		freopen("main.out", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	scan(n);
	fto (i, 1, n) {
		scan(a[i].x.x, a[i].x.y, a[i].y);
		s.pb(a[i].x.y);
	}
	sort(a + 1, a + 1 + n);
	sort(s.begin(), s.end());
	s.erase(unique(s.begin(), s.end()), s.end());
	data *root = new data({{0ll, 0ll}, nullptr, nullptr});

	ll cur, ans = 0;
	fto (i, 1, n) {
		int pos = lower_bound(s.begin(), s.end(), a[i].x.y) - s.begin();
		cur = a[i].x.x * a[i].x.y - a[i].y + query(root, 0, sz(s)-1, pos);
		pair<ll, ll> line(a[i].x.x, cur);
		update(root, 0, sz(s)-1, line);
		ans = max(ans, cur);
	}

	cout << ans << endl;

	#ifdef KITTENS
		cerr << 0.001*clock() << endl;
	#endif
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fto(i, s, e) for (int i = (s); i <= (e); ++i)
#define fto1(i, s, e) for (int i = (s); i < (e); ++i)
#define fdto(i, s, e) for (int i = (s); i >= (e); --i)
#define fit(var, it) for (auto it = (var).begin(); it != (var).end(); ++it)
#define frit(var, it) for (auto it = (var).rbegin(); it != (var).rend(); ++it)

#define endl '\n'
#define bug1(x, i) cout << #x << '[' << i << "] = " << x[i] << endl
#define bug2(x, i, j) cout << #x << '[' << i << "][" << j << "] = " << x[i][j] << endl
#define bug3(x, i, j, k) cout << #x << '[' << i << "][" << j << "][" << k << "] = " << x[i][j][k] << endl

#define bc __builtin_popcountll
#define onb(x, bit) (x & (1 << bit))
#define gcd __gcd
#define y1 ansdj

#define ll long long
#define ii pair<int, int>
#define x first
#define y second
#define pb push_back
#define sz(v) int((v).size())

template<class T1, class T2> ostream& operator<< (ostream &os, pair<T1, T2> const &v) {
	return os << '(' << v.x << ", " << v.y << ')';
}

char __c;
template<class T> bool scan(T &val) {
    for (__c = getchar(); __c != '-' && __c != EOF && (__c < '0' || __c > '9'); __c = getchar()); if (__c == EOF) return 0;
    bool neg = (__c == '-'); if (neg) val = 0; else val = __c - '0';
    for (__c = getchar(); __c >= '0' && __c <= '9'; __c = getchar()) val = val*10 + __c - '0';
    if (neg) val = -val; return 1;
}
bool scan(char &c) { c = getchar(); return c != EOF; }
bool scan(string &s) {
	s = ""; for (__c = getchar(); __c == ' ' || __c == '\n'; __c = getchar()); if (__c == EOF) return 0;
	s += __c; for (__c = getchar(); __c != ' ' && __c != '\n' && __c != EOF; __c = getchar()) s += __c; return 1;
}
template<class T, class... Args> bool scan(T &val, Args&... args) { scan(val); return scan(args...); }

double const pi = acos(-1);
#define oo 1000000007
#define OO 1000000000000000003LL
#define maxn 1000003

struct data {
	pair<ll, ll> line;
	int lid, rid;
};

int n;
pair<pair<ll, ll>, ll> a[maxn];
vector<data> node;

ll get(pair<ll, ll> &line, ll x) {
	return line.x*x + line.y;
}

void extend(int root, int l, int r) {
	if (node[root].lid > -1) return;
	node[root].lid = sz(node); node.pb({{0, 0}, -1, -1});
	node[root].rid = sz(node); node.pb({{0, 0}, -1, -1});
}

ll query(int root, int l, int r, ll pos) {
	if (l > pos || r < pos) return -OO;
	ll res = get(node[root].line, pos);
	if (l == r) return res;
	int mid = (l+r)/2;
	extend(root, l, r);
	return max(res, max(query(node[root].lid, l, mid, pos), query(node[root].rid, mid+1, r, pos)));
}

void update(int root, int l, int r, pair<ll, ll> &line) {
	ll lval = get(node[root].line, l), lline = get(line, l);
	ll rval = get(node[root].line, r), rline = get(line, r);
	if (lval >= lline && rval >= rline) return;
	if (lval <= lline && rval <= rline) {
		node[root].line = line;
		return;
	}
	int mid = (l+r)/2;
	extend(root, l, r);
	ll mval = get(node[root].line, mid), mline = get(line, mid);
	if (lval >= lline && mval >= mline) {
		update(node[root].rid, mid+1, r, line);
		return;
	}
	if (lval <= lline && mval <= mline) {
		update(node[root].rid, mid+1, r, line);
		node[root].line = line;
		return;
	}
	mval = get(node[root].line, mid+1); mline = get(line, mid+1);
	if (mval >= mline && rval >= rline) {
		update(node[root].lid, l, mid, line);
		return;
	}
	if (mval <= mline && rval <= rline) {
		update(node[root].lid, l, mid, line);
		node[root].line = line;
		return;
	}
	update(node[root].lid, l, mid, line);
	update(node[root].rid, mid+1, r, line);
}

int main() {
	#ifdef KITTENS
		freopen("main.inp", "r", stdin);
		freopen("main.out", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	cin >> n;
	fto (i, 1, n) {
		cin >> a[i].x.x >> a[i].x.y >> a[i].y;
	}
	sort(a + 1, a + 1 + n);

	node.reserve(4*maxn);
	node.pb({{0, 0}, -1, -1});
	ll cur, ans = 0;
	fto (i, 1, n) {
		cur = a[i].x.x * a[i].x.y - a[i].y + max(0ll, query(0, 1, 1e9, a[i].x.y));
		pair<ll, ll> line(-a[i].x.x, cur);
		update(0, 1, 1e9, line);
		ans = max(ans, cur);
	}

	cout << ans << endl;

	#ifdef KITTENS
		cerr << 0.001*clock() << endl;
	#endif
	return 0;
}


#include <bits/stdc++.h>
#define maxN 1000002
#define ll long long
using namespace std;

//FILE *fin = freopen("e.in", "r", stdin);

struct Rectangle
{
    int x, y;
    ll a;
    bool operator < (const Rectangle &ot) const
    {
        return x < ot.x; // <=> y > ot.y
    }
};
vector < Rectangle > v;

deque < int > d;
ll dp[maxN];

ll ans;

ll F(int i, int j)
{
    return 1LL * v[i].y * (-v[j].x) + dp[j];
}
int main()
{
    int n;
    scanf("%d", &n);
    v.resize(n);
    for (int i = 0; i < n; ++ i)
        scanf("%d%d%lld", &v[i].x, &v[i].y, &v[i].a);

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

    int top = 1;
    ans = dp[0] = 1LL * v[0].x * v[0].y - v[0].a;
    d.push_back(0);
    for (int i = 1; i < n; ++ i)
    {
        ll Ai = 1LL * v[i].x * v[i].y - v[i].a;
        dp[i] = Ai;
        while (top > 1)
        {
            int prv1 = d.back(), prv2;
            d.pop_back();
            prv2 = d.back();
            if (F(i, prv1) <= F(i, prv2))
            {
                d.push_back(prv1);
                break;
            }
            -- top;
        }
        while (top > 1)
        {
            int prv1 = d.front(), prv2;
            d.pop_front();
            prv2 = d.front();
            if (F(i, prv1) > F(i, prv2))
            {
                d.push_front(prv1);
                break;
            }
            -- top;
        }
        dp[i] = max(dp[i], Ai + F(i, d.front()));
        ans = max(ans, dp[i]);

        while (!d.empty() && 1LL * v[i].y * (v[i].x - v[d.back()].x) < (dp[i] - dp[d.back()]))
        {
            d.pop_back();
            -- top;
        }
        d.push_back(i);
        ++ top;
    }
    printf("%lld\n", ans);
    return 0;
}


#include <bits/stdc++.h>
#define maxN 1000002
#define ll long long
using namespace std;

//FILE *fin = freopen("e.in", "r", stdin);

struct Rectangle
{
    int x, y;
    ll a;
    bool operator < (const Rectangle &ot) const
    {
        return x < ot.x; // <=> y > ot.y
    }
};
vector < Rectangle > v;

deque < int > d;
ll dp[maxN];

ll ans;

ll F(int i, int j)
{
    return 1LL * v[i].y * (-v[j].x) + dp[j];
}
int main()
{
    int n;
    scanf("%d", &n);
    v.resize(n);
    for (int i = 0; i < n; ++ i)
        scanf("%d%d%lld", &v[i].x, &v[i].y, &v[i].a);

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

    int top = 1;
    ans = dp[0] = 1LL * v[0].x * v[0].y - v[0].a;
    d.push_back(0);
    for (int i = 1; i < n; ++ i)
    {
        ll Ai = 1LL * v[i].x * v[i].y - v[i].a;
        dp[i] = Ai;
        while (top > 1)
        {
            int prv1 = d.back(), prv2;
            d.pop_back();
            prv2 = d.back();
            if (F(i, prv1) > F(i, prv2))
            {
                d.push_back(prv1);
                break;
            }
            -- top;
        }
        while (top > 1)
        {
            int prv1 = d.front(), prv2;
            d.pop_front();
            prv2 = d.front();
            if (F(i, prv1) > F(i, prv2))
            {
                d.push_front(prv1);
                break;
            }
            -- top;
        }
        dp[i] = max(dp[i], Ai + F(i, d.front()));
        ans = max(ans, dp[i]);

        while (!d.empty() && 1LL * v[i].y * (v[i].x - v[d.back()].x) < (dp[i] - dp[d.back()]))
        {
            d.pop_back();
            -- top;
        }
        d.push_back(i);
        ++ top;
    }
    printf("%lld\n", ans);
    return 0;
}


#include <bits/stdc++.h>
#define maxN 1000002
#define ll long long
using namespace std;

//FILE *fin = freopen("e.in", "r", stdin);

struct Rectangle
{
    int x, y;
    ll a;
    bool operator < (const Rectangle &ot) const
    {
        if (x == ot.x)
            while(1);
        return y > ot.y; // <=> y > ot.y
    }
};
vector < Rectangle > v;

deque < int > d;
ll dp[maxN];

ll F(int i, int j)
{
    return 1LL * v[i].y * (-v[j].x) + dp[j];
}
int main()
{
    int n;
    scanf("%d", &n);
    v.resize(n);
    for (int i = 0; i < n; ++ i)
        scanf("%d%d%lld", &v[i].x, &v[i].y, &v[i].a);

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

    int top = 1;
    dp[0] = 1LL * v[0].x * v[0].y - v[0].a;
    d.push_back(0);
    for (int i = 1; i < n; ++ i)
    {
        ll Ai = 1LL * v[i].x * v[i].y - v[i].a;
        dp[i] = max(dp[i - 1], Ai);
        while (top > 1)
        {
            int prv1 = d.front(), prv2;
            d.pop_front();
            prv2 = d.front();
            if (F(i, prv1) > F(i, prv2))
            {
                d.push_front(prv1);
                break;
            }
            -- top;
        }
        dp[i] = max(dp[i], Ai + F(i, d.front()));
        while (top && F(i, d.back()) <= F(i, i))
        {
            d.pop_back();
            -- top;
        }
        d.push_back(i);
        ++ top;
    }
    printf("%lld\n", dp[n - 1]);
    return 0;
}


#include <bits/stdc++.h>
#define maxN 1000002
#define ll long long
using namespace std;

//FILE *fin = freopen("e.in", "r", stdin);

struct Rectangle
{
    int x, y;
    ll a;
    bool operator < (const Rectangle &ot) const
    {
        return x < ot.x; // <=> y > ot.y
    }
};
vector < Rectangle > v;

deque < int > d;
ll dp[maxN];

ll ans;

ll F(int i, int j)
{
    return 1LL * v[i].y * (-v[j].x) + dp[j];
}
int main()
{
    int n;
    scanf("%d", &n);
    v.resize(n);
    for (int i = 0; i < n; ++ i)
        scanf("%d%d%lld", &v[i].x, &v[i].y, &v[i].a);

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

    int top = 1;
    ans = dp[0] = 1LL * v[0].x * v[0].y - v[0].a;
    d.push_back(0);
    for (int i = 1; i < n; ++ i)
    {
        ll Ai = 1LL * v[i].x * v[i].y - v[i].a;
        dp[i] = Ai;
        while (top > 1)
        {
            int prv1 = d.back(), prv2;
            d.pop_back();
            prv2 = d.back();
            if (F(i, prv1) < F(i, prv2))
            {
                d.push_back(prv1);
                break;
            }
            -- top;
        }
        while (top > 1)
        {
            int prv1 = d.front(), prv2;
            d.pop_front();
            prv2 = d.front();
            if (F(i, prv1) > F(i, prv2))
            {
                d.push_front(prv1);
                break;
            }
            -- top;
        }
        dp[i] = max(dp[i], Ai + F(i, d.front()));
        ans = max(ans, dp[i]);

        while (!d.empty() && 1LL * v[i].y * (v[i].x - v[d.back()].x) < (dp[i] - dp[d.back()]))
        {
            d.pop_back();
            -- top;
        }
        d.push_back(i);
        ++ top;
    }
    printf("%lld\n", ans);
    return 0;
}


#include <bits/stdc++.h>
#define maxN 1000002
#define ll long long
using namespace std;

//FILE *fin = freopen("e.in", "r", stdin);

struct Rectangle
{
    int x, y;
    ll a;
    bool operator < (const Rectangle &ot) const
    {
        return x < ot.x; // <=> y > ot.y
    }
};
vector < Rectangle > v;

deque < int > d;
ll dp[maxN];

ll ans;

ll F(int i, int j)
{
    return 1LL * v[i].y * (-v[j].x) + dp[j];
}
int main()
{
    int n;
    scanf("%d", &n);
    v.resize(n);
    for (int i = 0; i < n; ++ i)
        scanf("%d%d%lld", &v[i].x, &v[i].y, &v[i].a);

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

    int top = 1;
    ans = dp[0] = 1LL * v[0].x * v[0].y - v[0].a;
    d.push_back(0);
    for (int i = 1; i < n; ++ i)
    {
        ll Ai = 1LL * v[i].x * v[i].y - v[i].a;
        dp[i] = Ai;
        while (top > 1)
        {
            int prv1 = d.front(), prv2;
            d.pop_front();
            prv2 = d.front();
            if (F(i, prv1) > F(i, prv2))
            {
                d.push_front(prv1);
                break;
            }
            -- top;
        }
        dp[i] = max(dp[i], Ai + F(i, d.front()));
        ans = max(ans, dp[i]);

        while (top > 1)
        {
             int prv1 = d.back(), prv2;
            d.pop_back();
            prv2 = d.back();
            /* dp[i] - v[i].x * y1 >= dp[prv1] - v[prv1].x * y
               dp[prv1] - v[prv1].x * y2 >= dp[prv2] - v[prv1].x
               dp[i] - dp[prv1] / v[i].x - v[prv1].x < dp[prv1] - dp[prv2] / (v[prv1].x - v[prv2].x) */
            if ((dp[i] - dp[prv1]) * (v[prv1].x - v[prv2].x) >= (dp[prv1] - dp[prv2]) * (v[i].x - v[prv1].x))
               {
                   d.push_back(prv1);
                   break;
               }-- top;
        }
        d.push_back(i);
        ++ top;
    }
    printf("%lld\n", ans);
    return 0;
}


#include <bits/stdc++.h>
#define maxN 1000002
#define ll long long
using namespace std;

//FILE *fin = freopen("e.in", "r", stdin);

struct Rectangle
{
    int x, y;
    ll a;
    bool operator < (const Rectangle &ot) const
    {
        if (x == ot.x)
            while(1);
        return y > ot.y; // <=> y > ot.y
    }
};
vector < Rectangle > v;

deque < int > d;
ll dp[maxN];

ll F(int i, int j)
{
    return 1LL * v[i].y * (-v[j].x) + dp[j];
}
int main()
{
    int n;
    scanf("%d", &n);
    v.resize(n);
    for (int i = 0; i < n; ++ i)
        scanf("%d%d%lld", &v[i].x, &v[i].y, &v[i].a);

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

    int top = 1;
    dp[0] = 1LL * v[0].x * v[0].y - v[0].a;
    d.push_back(0);
    for (int i = 1; i < n; ++ i)
    {
        ll Ai = 1LL * v[i].x * v[i].y - v[i].a;
        dp[i] = max(dp[i - 1], Ai);
        while (top > 1)
        {
            int prv1 = d.front(), prv2;
            d.pop_front();
            prv2 = d.front();
            if (F(i, prv1) > F(i, prv2))
            {
                d.push_front(prv1);
                break;
            }
            -- top;
        }
        dp[i] = max(dp[i], Ai + F(i, d.front()));
        while (!d.empty() && 1LL * v[i].y * (v[i].x - v[d.back()].x) < (dp[i] - dp[d.back()]))
        {
            d.pop_back();
            -- top;
        }
        d.push_back(i);
        ++ top;
    }
    printf("%lld\n", dp[n - 1]);
    return 0;
}


#include <bits/stdc++.h>
#define maxN 1000002
#define ll long long
using namespace std;

//FILE *fin = freopen("e.in", "r", stdin);

struct Rectangle
{
    int x, y;
    ll a;
    bool operator < (const Rectangle &ot) const
    {
        return x < ot.x; // <=> y > ot.y
    }
};
vector < Rectangle > v;

deque < int > d;
ll dp[maxN];

ll ans;

ll F(int i, int j)
{
    return 1LL * v[i].y * (-v[j].x) + dp[j];
}
int main()
{
    int n;
    scanf("%d", &n);
    v.resize(n);
    for (int i = 0; i < n; ++ i)
        scanf("%d%d%lld", &v[i].x, &v[i].y, &v[i].a);

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

    int top = 1;
    ans = dp[0] = 1LL * v[0].x * v[0].y - v[0].a;
    d.push_back(0);
    for (int i = 1; i < n; ++ i)
    {
        ll Ai = 1LL * v[i].x * v[i].y - v[i].a;
        dp[i] = Ai;
        while (top > 1)
        {
            int prv1 = d.front(), prv2;
            d.pop_front();
            prv2 = d.front();
            if (F(i, prv1) > F(i, prv2))
            {
                d.push_front(prv1);
                break;
            }
            -- top;
        }
        dp[i] = max(dp[i], Ai + F(i, d.front()));
        ans = max(ans, dp[i]);

        while (top > 1)
        {
            int prv1 = d.back(), prv2;
            d.pop_back();
            prv2 = d.back();
            /* dp[i] - v[i].x * y1 >= dp[prv1] - v[prv1].x * y
               dp[prv1] - v[prv1].x * y2 >= dp[prv2] - v[prv1].x
               dp[i] - dp[prv1] / v[i].x - v[prv1].x < dp[prv1] - dp[prv2] / (v[prv1].x - v[prv2].x) */
            if (1.0 * (dp[i] - dp[prv1]) / (v[i].x - v[prv1].x) <= 1.0 * (dp[prv1] - dp[prv2]) / (v[prv1].x - v[prv2].x))
            {
                d.push_back(prv1);
                break;
            }-- top;
        }
        d.push_back(i);
        ++ top;
    }
    printf("%lld\n", ans);
    return 0;
}


#include <bits/stdc++.h>
#define maxN 1000002
#define ll long long
using namespace std;

//FILE *fin = freopen("e.in", "r", stdin);

struct Rectangle
{
    int x, y;
    ll a;
    bool operator < (const Rectangle &ot) const
    {
        if (x == ot.x)
            while(1);
        return y > ot.y; // <=> y > ot.y
    }
};
vector < Rectangle > v;

deque < int > d;
ll dp[maxN];

ll ans;

ll F(int i, int j)
{
    return 1LL * v[i].y * (-v[j].x) + dp[j];
}
int main()
{
    int n;
    scanf("%d", &n);
    v.resize(n);
    for (int i = 0; i < n; ++ i)
        scanf("%d%d%lld", &v[i].x, &v[i].y, &v[i].a);

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

    int top = 1;
    ans = dp[0] = 1LL * v[0].x * v[0].y - v[0].a;
    d.push_back(0);
    for (int i = 1; i < n; ++ i)
    {
        ll Ai = 1LL * v[i].x * v[i].y - v[i].a;
        dp[i] = Ai;
        while (top > 1)
        {
            int prv1 = d.front(), prv2;
            d.pop_front();
            prv2 = d.front();
            if (F(i, prv1) > F(i, prv2))
            {
                d.push_front(prv1);
                break;
            }
            -- top;
        }
        dp[i] = max(dp[i], Ai + F(i, d.front()));
        ans = max(ans, dp[i]);
        while (!d.empty() && 1LL * v[i].y * (v[i].x - v[d.back()].x) < (dp[i] - dp[d.back()]))
        {
            d.pop_back();
            -- top;
        }
        d.push_back(i);
        ++ top;
    }
    printf("%lld\n", ans);
    return 0;
}


#include <bits/stdc++.h>
#define maxN 1000002
#define ll long long
using namespace std;

//FILE *fin = freopen("e.in", "r", stdin);

struct Rectangle
{
    int x, y;
    ll a;
    bool operator < (const Rectangle &ot) const
    {
        return x < ot.x; // <=> y > ot.y
    }
};
vector < Rectangle > v;

deque < int > d;
ll dp[maxN];

ll F(int i, int j)
{
    return 1LL * v[i].y * (-v[j].x) + dp[j];
}
int main()
{
    int n;
    scanf("%d", &n);
    v.resize(n);
    for (int i = 0; i < n; ++ i)
        scanf("%d%d%lld", &v[i].x, &v[i].y, &v[i].a);

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

    int top = 1;
    dp[0] = 1LL * v[0].x * v[0].y - v[0].a;
    d.push_back(0);
    for (int i = 1; i < n; ++ i)
    {
        ll Ai = 1LL * v[i].x * v[i].y - v[i].a;
        dp[i] = max(dp[i - 1], Ai);
        while (top > 1)
        {
            int prv1 = d.front(), prv2;
            d.pop_front();
            prv2 = d.front();
            if (F(i, prv1) > F(i, prv2))
            {
                d.push_front(prv1);
                break;
            }
            -- top;
        }
        dp[i] = max(dp[i], Ai + F(i, d.front()));
        while (top && F(i, d.back()) <= F(i, i))
        {
            d.pop_back();
            -- top;
        }
        d.push_back(i);
        ++ top;
    }
    printf("%lld\n", dp[n - 1]);
    return 0;
}


#include <bits/stdc++.h>
#define maxN 1000002
#define ll long long
using namespace std;

//FILE *fin = freopen("e.in", "r", stdin);

struct Rectangle
{
    int x, y, a;
    bool operator < (const Rectangle &ot) const
    {
        return x < ot.x; // <=> y > ot.y
    }
};
vector < Rectangle > v;

deque < int > d;
ll dp[maxN];

ll F(int i, int j)
{
    return 1LL * v[i].y * (-v[j].x) + dp[j];
}
int main()
{
    int n;
    scanf("%d", &n);
    v.resize(n);
    for (int i = 0; i < n; ++ i)
        scanf("%d%d%d", &v[i].x, &v[i].y, &v[i].a);

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

    int top = 1;
    dp[0] = 1LL * v[0].x * v[0].y - v[0].a;
    d.push_back(0);
    for (int i = 1; i < n; ++ i)
    {
        ll Ai = 1LL * v[i].x * v[i].y - v[i].a;
        dp[i] = max(dp[i - 1], Ai);
        while (top > 1)
        {
            int prv1 = d.front(), prv2;
            d.pop_front();
            prv2 = d.front();
            if (F(i, prv1) > F(i, prv2))
            {
                d.push_front(prv1);
                break;
            }
            -- top;
        }
        dp[i] = max(dp[i], Ai + F(i, d.front()));
        while (top && F(i, d.back()) <= F(i, i))
        {
            d.pop_back();
            -- top;
        }
        d.push_back(i);
        ++ top;
    }
    printf("%lld\n", dp[n - 1]);
    return 0;
}


#include <bits/stdc++.h>
#define maxN 1000002
#define ll long long
using namespace std;

//FILE *fin = freopen("e.in", "r", stdin);

struct Rectangle
{
    int x, y;
    ll a;
    bool operator < (const Rectangle &ot) const
    {
        if (x == ot.x)
            while(1);
        return y > ot.y; // <=> y > ot.y
    }
};
vector < Rectangle > v;

deque < int > d;
ll dp[maxN];

ll F(int i, int j)
{
    return 1LL * v[i].y * (-v[j].x) + dp[j];
}
int main()
{
    int n;
    scanf("%d", &n);
    v.resize(n);
    for (int i = 0; i < n; ++ i)
        scanf("%d%d%lld", &v[i].x, &v[i].y, &v[i].a);

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

    int top = 1;
    dp[0] = 1LL * v[0].x * v[0].y - v[0].a;
    d.push_back(0);
    for (int i = 1; i < n; ++ i)
    {
        ll Ai = 1LL * v[i].x * v[i].y - v[i].a;
        dp[i] = max(dp[i - 1], Ai);
        while (top > 1)
        {
            int prv1 = d.front(), prv2;
            d.pop_front();
            prv2 = d.front();
            if (F(i, prv1) > F(i, prv2))
            {
                d.push_front(prv1);
                break;
            }
            -- top;
        }
        dp[i] = max(dp[i], Ai + F(i, d.front()));
        while (i < n - 1 && top && F(i + 1, d.back()) < F(i + 1, i))
        {
            d.pop_back();
            -- top;
        }
        d.push_back(i);
        ++ top;
    }
    printf("%lld\n", dp[n - 1]);
    return 0;
}


#include <bits/stdc++.h>
#define maxN 1000002
#define ll long long
using namespace std;

//FILE *fin = freopen("e.in", "r", stdin);

struct Rectangle
{
    int x, y;
    ll a;
    bool operator < (const Rectangle &ot) const
    {
        return x < ot.x; // <=> y > ot.y
    }
};
vector < Rectangle > v;

deque < int > d;
ll dp[maxN];

ll ans;

ll F(int i, int j)
{
    return 1LL * v[i].y * (-v[j].x) + dp[j];
}
int main()
{
    int n;
    scanf("%d", &n);
    v.resize(n);
    for (int i = 0; i < n; ++ i)
        scanf("%d%d%lld", &v[i].x, &v[i].y, &v[i].a);

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

    int top = 1;
    ans = dp[0] = 1LL * v[0].x * v[0].y - v[0].a;
    d.push_back(0);
    for (int i = 1; i < n; ++ i)
    {
        ll Ai = 1LL * v[i].x * v[i].y - v[i].a;
        dp[i] = Ai;
        while (top > 1)
        {
            int prv1 = d.front(), prv2;
            d.pop_front();
            prv2 = d.front();
            if (F(i, prv1) > F(i, prv2))
            {
                d.push_front(prv1);
                break;
            }
            -- top;
        }
        dp[i] = max(dp[i], Ai + F(i, d.front()));
        ans = max(ans, dp[i]);

        while (top > 1)
        {
            int prv1 = d.back(), prv2;
            d.pop_back();
            prv2 = d.back();
            /* dp[i] - v[i].x * y1 >= dp[prv1] - v[prv1].x * y
               dp[prv1] - v[prv1].x * y2 >= dp[prv2] - v[prv1].x
               dp[i] - dp[prv1] / v[i].x - v[prv1].x < dp[prv1] - dp[prv2] / (v[prv1].x - v[prv2].x) */
            if (1.0 * (dp[i] - dp[prv1]) / (v[i].x - v[prv1].x) >= 1.0 * (dp[prv1] - dp[prv2]) / (v[prv1].x - v[prv2].x))
            {
                d.push_back(prv1);
                break;
            }-- top;
        }
        d.push_back(i);
        ++ top;
    }
    printf("%lld\n", ans);
    return 0;
}


#include <bits/stdc++.h>
#define maxN 1000002
#define ll long long
using namespace std;

//FILE *fin = freopen("e.in", "r", stdin);

struct Rectangle
{
    int x, y;
    ll a;
    bool operator < (const Rectangle &ot) const
    {
        return x < ot.x; // <=> y > ot.y
    }
};
vector < Rectangle > v;

deque < int > d;
ll dp[maxN];

ll ans;

ll F(int i, int j)
{
    return 1LL * v[i].y * (-v[j].x) + dp[j];
}
int main()
{
    int n;
    scanf("%d", &n);
    v.resize(n);
    for (int i = 0; i < n; ++ i)
        scanf("%d%d%lld", &v[i].x, &v[i].y, &v[i].a);

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

    int top = 1;
    ans = dp[0] = 1LL * v[0].x * v[0].y - v[0].a;
    d.push_back(0);
    for (int i = 1; i < n; ++ i)
    {
        ll Ai = 1LL * v[i].x * v[i].y - v[i].a;
        dp[i] = Ai;
        while (top > 1)
        {
            int prv1 = d.front(), prv2;
            d.pop_front();
            prv2 = d.front();
            if (F(i, prv1) > F(i, prv2))
            {
                d.push_front(prv1);
                break;
            }
            -- top;
        }
        dp[i] = max(dp[i], Ai + F(i, d.front()));
        ans = max(ans, dp[i]);

        while (top > 1)
        {
            int prv1 = d.back(), prv2;
            d.pop_back();
            prv2 = d.back();
            /* dp[i] - v[i].x * y1 >= dp[prv1] - v[prv1].x * y
               dp[prv1] - v[prv1].x * y2 >= dp[prv2] - v[prv1].x
               dp[i] - dp[prv1] / v[i].x - v[prv1].x < dp[prv1] - dp[prv2] / (v[prv1].x - v[prv2].x) */
            if (1.0 * (dp[i] - dp[prv1]) * (v[i].x - v[prv1].x) <= 1.0 * (dp[prv1] - dp[prv2]) * (v[prv1].x - v[prv2].x))
            {
                d.push_back(prv1);
                break;
            }-- top;
        }
        d.push_back(i);
        ++ top;
    }
    printf("%lld\n", ans);
    return 0;
}


#include <bits/stdc++.h>
#define maxN 1000002
#define ll long long
using namespace std;

//FILE *fin = freopen("e.in", "r", stdin);

struct Rectangle
{
    int x, y;
    ll a;
    bool operator < (const Rectangle &ot) const
    {
        return x < ot.x; // <=> y > ot.y
    }
};
vector < Rectangle > v;

deque < int > d;
ll dp[maxN];

ll ans;

ll F(int i, int j)
{
    return 1LL * v[i].y * (-v[j].x) + dp[j];
}
int main()
{
    int n;
    scanf("%d", &n);
    v.resize(n);
    for (int i = 0; i < n; ++ i)
        scanf("%d%d%lld", &v[i].x, &v[i].y, &v[i].a);

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

    int top = 1;
    ans = dp[0] = 1LL * v[0].x * v[0].y - v[0].a;
    d.push_back(0);
    for (int i = 1; i < n; ++ i)
    {
        ll Ai = 1LL * v[i].x * v[i].y - v[i].a;
        dp[i] = Ai;
        while (top > 1)
        {
            int prv1 = d.front(), prv2;
            d.pop_front();
            prv2 = d.front();
            if (F(i, prv1) > F(i, prv2))
            {
                d.push_front(prv1);
                break;
            }
            -- top;
        }
        dp[i] = max(dp[i], Ai + F(i, d.front()));
        ans = max(ans, dp[i]);

        while (top > 1)
        {
            int prv1 = d.back(), prv2;
            d.pop_back();
            prv2 = d.back();
            /* dp[i] - v[i].x * y1 >= dp[prv1] - v[prv1].x * y
               dp[prv1] - v[prv1].x * y2 >= dp[prv2] - v[prv1].x
               dp[i] - dp[prv1] / v[i].x - v[prv1].x < dp[prv1] - dp[prv2] / (v[prv1].x - v[prv2].x) */
            if (1.0 * (dp[i] - dp[prv1]) * (v[i].x - v[prv1].x) >= 1.0 * (dp[prv1] - dp[prv2]) * (v[prv1].x - v[prv2].x))
            {
                d.push_back(prv1);
                break;
            }-- top;
        }
        d.push_back(i);
        ++ top;
    }
    printf("%lld\n", ans);
    return 0;
}


#include<bits/stdc++.h>

#define pb push_back
#define fi first
#define se second
#define LL long long
#define debug(x) cerr << #x << " = " << (x) << " ";

using namespace std;

typedef pair<LL, LL> ii;
typedef pair<int, ii> pii;
typedef vector<int> vi;
typedef vector<ii> vii;

const LL oo = 1e17 + 7;
const int maxN = 1e6 + 7;

struct MODE
{
	LL X, Y, A;
} rec[maxN];

LL n, it, cnt, X[maxN], Y[maxN], a[maxN], f[maxN];
ii point[maxN];

long long readInt () {
	bool minus = false;
	long long result = 0;
	char ch;
	ch = getchar();
	while (true) {
		if (ch == '-') break;
		if (ch >= '0' && ch <= '9') break;
		ch = getchar();
	}
	if (ch == '-') minus = true; else result = ch-'0';
	while (true) {
		ch = getchar();
		if (ch < '0' || ch > '9') break;
		result = result*10 + (ch - '0');
	}
	if (minus)
		return -result;
	else
		return result;
}

bool cmp(MODE A, MODE B)
{
	return A.X < B.X;
}

bool bad(ii A, ii B, ii C)
{
	return 1.0 * (C.se - A.se) * (A.fi - B.fi) <= 1.0 * (B.se - A.se) * (A.fi - C.fi);
}

LL get(LL X)
{
	if (it >= cnt)	it = cnt;
	if (it == 0)	return oo;
	while (it + 1 <= cnt && point[it + 1].fi * X + point[it + 1].se <= point[it].fi * X + point[it].se)	it++;
	return point[it].fi * X + point[it].se;
}

// LL Get(ii d, LL X)
// {
// 	return d.fi * X + d.se;
// }

// LL Query(LL X)
// {
// 	int l = 0, r = cnt + 1;
// 	LL cur = -oo;
// 	while (r - l > 2)
// 	{
// 		int m1 = (l + l + r) / 3;	int m2 = (l + r + r) / 3;
// 		if (Get(point[m1], X) == Get(point[m2], X))	l = m1, r = m2;
// 		else
// 		if (Get(point[m1], X) < Get(point[m2],X))	l = m1;
// 		else	r = m2;
// 	}
// 	if (l == 0)	l = 1;	if (r >= cnt)	r = cnt;
// 	for (int i = l; i <= r; i++)
// 		cur = max(cur, Get(point[i], X));
// 	return cur;
// }

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	n = readInt();
	for (int i = 1; i <= n; i++)
	{
		rec[i].X = readInt();
		rec[i].Y = readInt();
		rec[i].A = readInt();
	}
	sort(rec + 1, rec + n + 1, cmp);
	cnt = 0;	it = 1;
	LL ans = -oo;
	for (int i = 1; i <= n; i++)
	{
		f[i] = rec[i].X * rec[i].Y - rec[i].A;
		f[i] = max(f[i], -get(-rec[i].Y) + rec[i].X * rec[i].Y - rec[i].A);
		ii newpoint = ii(-rec[i].X, -f[i]);
		while (cnt >= 2 && bad(point[cnt - 1], point[cnt], newpoint))	cnt--;
		point[++cnt] = newpoint;
	}
	for (int i = 1; i <= n; i++)	ans = max(ans, f[i]);
	cout << ans;
//	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}


#include<bits/stdc++.h>

#define pb push_back
#define fi first
#define se second
#define LL long long
#define debug(x) cerr << #x << " = " << (x) << " ";

using namespace std;

typedef pair<LL, LL> ii;
typedef pair<int, ii> pii;
typedef vector<int> vi;
typedef vector<ii> vii;

const LL oo = 1e17 + 7;
const int maxN = 1e6 + 7;

struct MODE
{
	LL X, Y, A;
} rec[maxN];

LL n, it, cnt, X[maxN], Y[maxN], a[maxN], f[maxN];
ii point[maxN];

long long readInt () {
	bool minus = false;
	long long result = 0;
	char ch;
	ch = getchar();
	while (true) {
		if (ch == '-') break;
		if (ch >= '0' && ch <= '9') break;
		ch = getchar();
	}
	if (ch == '-') minus = true; else result = ch-'0';
	while (true) {
		ch = getchar();
		if (ch < '0' || ch > '9') break;
		result = result*10 + (ch - '0');
	}
	if (minus)
		return -result;
	else
		return result;
}

bool cmp(MODE A, MODE B)
{
	return A.X < B.X;
}

bool bad(ii A, ii B, ii C)
{
	return 1.0 * (C.se - A.se) * (A.fi - B.fi) <= 1.0 * (B.se - A.se) * (A.fi - C.fi);
}

LL get(LL X)
{
	if (it >= cnt)	it = cnt;
	while (it + 1 <= cnt && point[it + 1].fi * X + point[it + 1].se <= point[it].fi * X + point[it].se)	it++;
	return point[it].fi * X + point[it].se;
}

// LL Get(ii d, LL X)
// {
// 	return d.fi * X + d.se;
// }

// LL Query(LL X)
// {
// 	int l = 0, r = cnt + 1;
// 	LL cur = -oo;
// 	while (r - l > 2)
// 	{
// 		int m1 = (l + l + r) / 3;	int m2 = (l + r + r) / 3;
// 		if (Get(point[m1], X) == Get(point[m2], X))	l = m1, r = m2;
// 		else
// 		if (Get(point[m1], X) < Get(point[m2],X))	l = m1;
// 		else	r = m2;
// 	}
// 	if (l == 0)	l = 1;	if (r >= cnt)	r = cnt;
// 	for (int i = l; i <= r; i++)
// 		cur = max(cur, Get(point[i], X));
// 	return cur;
// }

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	n = readInt();
	for (int i = 1; i <= n; i++)
	{
		rec[i].X = readInt();
		rec[i].Y = readInt();
		rec[i].A = readInt();
	}
	sort(rec + 1, rec + n + 1, cmp);
	cnt = 0;	it = 1;
	point[++cnt] = ii(0, 0);
	LL ans = -oo;
	for (int i = 1; i <= n; i++)
	{
		f[i] = rec[i].X * rec[i].Y - rec[i].A;
		f[i] = max(f[i], -get(-rec[i].Y) + rec[i].X * rec[i].Y - rec[i].A);
		ii newpoint = ii(-rec[i].X, -f[i]);
		while (cnt >= 2 && bad(point[cnt - 1], point[cnt], newpoint))	cnt--;
		point[++cnt] = newpoint;
	}
	for (int i = 1; i <= n; i++)	ans = max(ans, f[i]);
	cout << ans;
//	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}


#include<bits/stdc++.h>

#define pb push_back
#define fi first
#define se second
#define LL long long
#define debug(x) cerr << #x << " = " << (x) << " ";

using namespace std;

typedef pair<LL, LL> ii;
typedef pair<int, ii> pii;
typedef vector<int> vi;
typedef vector<ii> vii;

const LL oo = 1e17 + 7;
const int maxN = 1e6 + 7;

struct MODE
{
	LL X, Y, A;
} rec[maxN];

LL n, it, cnt, X[maxN], Y[maxN], a[maxN], f[maxN];
ii point[maxN];

long long readInt () {
	bool minus = false;
	long long result = 0;
	char ch;
	ch = getchar();
	while (true) {
		if (ch == '-') break;
		if (ch >= '0' && ch <= '9') break;
		ch = getchar();
	}
	if (ch == '-') minus = true; else result = ch-'0';
	while (true) {
		ch = getchar();
		if (ch < '0' || ch > '9') break;
		result = result*10 + (ch - '0');
	}
	if (minus)
		return -result;
	else
		return result;
}

bool cmp(MODE A, MODE B)
{
	return A.X < B.X;
}

bool bad(ii A, ii B, ii C)
{
	return 1.0 * (C.se - A.se) * (A.fi - B.fi) <= 1.0 * (B.se - A.se) * (A.fi - C.fi);
}

LL get(LL X)
{
	if (it >= cnt)	it = cnt;
	while (it + 1 <= cnt && point[it + 1].fi * X + point[it + 1].se >= point[it].fi * X + point[it].se)	it++;
	return point[it].fi * X + point[it].se;
}

// LL Get(ii d, LL X)
// {
// 	return d.fi * X + d.se;
// }

// LL Query(LL X)
// {
// 	int l = 0, r = cnt + 1;
// 	LL cur = -oo;
// 	while (r - l > 2)
// 	{
// 		int m1 = (l + l + r) / 3;	int m2 = (l + r + r) / 3;
// 		if (Get(point[m1], X) == Get(point[m2], X))	l = m1, r = m2;
// 		else
// 		if (Get(point[m1], X) < Get(point[m2],X))	l = m1;
// 		else	r = m2;
// 	}
// 	if (l == 0)	l = 1;	if (r >= cnt)	r = cnt;
// 	for (int i = l; i <= r; i++)
// 		cur = max(cur, Get(point[i], X));
// 	return cur;
// }

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	n = readInt();
	for (int i = 1; i <= n; i++)
	{
		rec[i].X = readInt();
		rec[i].Y = readInt();
		rec[i].A = readInt();
	}
	sort(rec + 1, rec + n + 1, cmp);
	cnt = 0; it = 1;
	LL ans = -oo;
	for (int i = 1; i <= n; i++)
	{
		f[i] = rec[i].X * rec[i].Y - rec[i].A;
		f[i] = max(f[i], get(-rec[i].Y) + rec[i].X * rec[i].Y - rec[i].A);
		ii newpoint = ii(rec[i].X, f[i]);
		while (cnt >= 2 && bad(point[cnt - 1], point[cnt], newpoint))	cnt--;
		point[++cnt] = newpoint;
	}
	for (int i = 1; i <= n; i++)	ans = max(ans, f[i]);
	cout << ans;
//	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}


#include<bits/stdc++.h>

#define pb push_back
#define fi first
#define se second
#define LL long long
#define debug(x) cerr << #x << " = " << (x) << " ";

using namespace std;

typedef pair<LL, LL> ii;
typedef pair<int, ii> pii;
typedef vector<int> vi;
typedef vector<ii> vii;

const LL oo = 1e17 + 7;
const int maxN = 1e6 + 7;

struct MODE
{
	LL X, Y, A;
} rec[maxN];

LL n, it, cnt, X[maxN], Y[maxN], a[maxN], f[maxN];
ii point[maxN];

long long readInt () {
	bool minus = false;
	long long result = 0;
	char ch;
	ch = getchar();
	while (true) {
		if (ch == '-') break;
		if (ch >= '0' && ch <= '9') break;
		ch = getchar();
	}
	if (ch == '-') minus = true; else result = ch-'0';
	while (true) {
		ch = getchar();
		if (ch < '0' || ch > '9') break;
		result = result*10 + (ch - '0');
	}
	if (minus)
		return -result;
	else
		return result;
}

bool cmp(MODE A, MODE B)
{
	return A.X < B.X;
}

bool bad(ii A, ii B, ii C)
{
	return 1.0 * (C.se - A.se) * (A.fi - B.fi) <= 1.0 * (B.se - A.se) * (A.fi - C.fi);
}

LL get(LL X)
{
	if (it >= cnt)	it = cnt;
	while (it + 1 <= cnt && point[it + 1].fi * X + point[it + 1].se <= point[it].fi * X + point[it].se)	it++;
	if (it == 0)	return oo;
	return point[it].fi * X + point[it].se;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	n = readInt();
	for (int i = 1; i <= n; i++)
	{
		rec[i].X = readInt();
		rec[i].Y = readInt();
		rec[i].A = readInt();
	}
	sort(rec + 1, rec + n + 1, cmp);
	cnt = 0;	it = 1;
	LL ans = -oo;
	for (int i = 1; i <= n; i++)
	{
		f[i] = rec[i].X * rec[i].Y - rec[i].A;
		f[i] = max(f[i], -get(-rec[i].Y) + rec[i].X * rec[i].Y - rec[i].A);
		ii newpoint = ii(-rec[i].X, -f[i]);
		while (cnt >= 2 && bad(point[cnt - 1], point[cnt], newpoint))	cnt--;
		point[++cnt] = newpoint;
	}
	for (int i = 1; i <= n; i++)	ans = max(ans, f[i]);
	cout << ans;
//	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}


#include<bits/stdc++.h>

#define pb push_back
#define fi first
#define se second
#define LL long long
#define debug(x) cerr << #x << " = " << (x) << " ";

using namespace std;

typedef pair<LL, LL> ii;
typedef pair<int, ii> pii;
typedef vector<int> vi;
typedef vector<ii> vii;

const LL oo = 1e17 + 7;
const int maxN = 1e6 + 7;

struct MODE
{
	LL X, Y, A;
} rec[maxN];

LL n, it, cnt, X[maxN], Y[maxN], a[maxN], f[maxN];
ii point[maxN];

long long readInt () {
	bool minus = false;
	long long result = 0;
	char ch;
	ch = getchar();
	while (true) {
		if (ch == '-') break;
		if (ch >= '0' && ch <= '9') break;
		ch = getchar();
	}
	if (ch == '-') minus = true; else result = ch-'0';
	while (true) {
		ch = getchar();
		if (ch < '0' || ch > '9') break;
		result = result*10 + (ch - '0');
	}
	if (minus)
		return -result;
	else
		return result;
}

bool cmp(MODE A, MODE B)
{
	return A.X < B.X;
}

bool bad(ii A, ii B, ii C)
{
	return 1.0 * (C.se - A.se) * (A.fi - B.fi) <= 1.0 * (B.se - A.se) * (A.fi - C.fi);
}

LL Get(ii d, LL X)
{
	return d.fi * X + d.se;
}

LL Query(LL X)
{
	int l = 0, r = cnt + 1;
	LL cur = -oo;
	while (r - l > 2)
	{
		int m1 = (l + l + r) / 3;	int m2 = (l + r + r) / 3;
		if (Get(point[m1], X) == Get(point[m2], X))	l = m1, r = m2;
		else
		if (Get(point[m1], X) < Get(point[m2],X))	l = m1;
		else	r = m2;
	}
	if (l == 0)	l = 1;	if (r >= cnt)	r = cnt;
	for (int i = l; i <= r; i++)
		cur = max(cur, Get(point[i], X));
	return cur;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	n = readInt();
	for (int i = 1; i <= n; i++)
	{
		rec[i].X = readInt();
		rec[i].Y = readInt();
		rec[i].A = readInt();
	}
	sort(rec + 1, rec + n + 1, cmp);
	cnt = 0; it = 1;
	LL ans = -oo;
	for (int i = 1; i <= n; i++)
	{
		f[i] = rec[i].X * rec[i].Y - rec[i].A;
		f[i] = max(f[i], Query(-rec[i].Y) + rec[i].X * rec[i].Y - rec[i].A);
		ii newpoint = ii(rec[i].X, f[i]);
		while (cnt >= 2 && bad(point[cnt - 1], point[cnt], newpoint))	cnt--;
		point[++cnt] = newpoint;
	}
	for (int i = 1; i <= n; i++)	ans = max(ans, f[i]);
	cout << ans;
	return 0;
}


#include<bits/stdc++.h>

#define pb push_back
#define fi first
#define se second
#define LL long long
#define debug(x) cerr << #x << " = " << (x) << " ";

using namespace std;

typedef pair<LL, LL> ii;
typedef pair<int, ii> pii;
typedef vector<int> vi;
typedef vector<ii> vii;

const LL oo = 1e17 + 7;
const int maxN = 1e6 + 7;

struct MODE
{
	LL X, Y, A;
} rec[maxN];

LL n, it, cnt, X[maxN], Y[maxN], a[maxN], f[maxN];
ii point[maxN];

long long readInt () {
	bool minus = false;
	long long result = 0;
	char ch;
	ch = getchar();
	while (true) {
		if (ch == '-') break;
		if (ch >= '0' && ch <= '9') break;
		ch = getchar();
	}
	if (ch == '-') minus = true; else result = ch-'0';
	while (true) {
		ch = getchar();
		if (ch < '0' || ch > '9') break;
		result = result*10 + (ch - '0');
	}
	if (minus)
		return -result;
	else
		return result;
}

bool cmp(MODE A, MODE B)
{
	return A.X < B.X;
}

bool bad(ii A, ii B, ii C)
{
	return 1.0 * (C.se - A.se) * (A.fi - B.fi) <= 1.0 * (B.se - A.se) * (A.fi - C.fi);
}

LL get(LL X)
{
	if (it >= cnt)	it = cnt;
	while (it + 1 <= cnt && point[it + 1].fi * X + point[it + 1].se <= point[it].fi * X + point[it].se)	it++;
	return point[it].fi * X + point[it].se;
}

// LL Get(ii d, LL X)
// {
// 	return d.fi * X + d.se;
// }

// LL Query(LL X)
// {
// 	int l = 0, r = cnt + 1;
// 	LL cur = -oo;
// 	while (r - l > 2)
// 	{
// 		int m1 = (l + l + r) / 3;	int m2 = (l + r + r) / 3;
// 		if (Get(point[m1], X) == Get(point[m2], X))	l = m1, r = m2;
// 		else
// 		if (Get(point[m1], X) < Get(point[m2],X))	l = m1;
// 		else	r = m2;
// 	}
// 	if (l == 0)	l = 1;	if (r >= cnt)	r = cnt;
// 	for (int i = l; i <= r; i++)
// 		cur = max(cur, Get(point[i], X));
// 	return cur;
// }

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	n = readInt();
	for (int i = 1; i <= n; i++)
	{
		rec[i].X = readInt();
		rec[i].Y = readInt();
		rec[i].A = readInt();
	}
	sort(rec + 1, rec + n + 1, cmp);
	cnt = 0; it = 1;
	LL ans = -oo;
	for (int i = 1; i <= n; i++)
	{
		f[i] = rec[i].X * rec[i].Y - rec[i].A;
		f[i] = max(f[i], -get(-rec[i].Y) + rec[i].X * rec[i].Y - rec[i].A);
		ii newpoint = ii(-rec[i].X, -f[i]);
		while (cnt >= 2 && bad(point[cnt - 1], point[cnt], newpoint))	cnt--;
		point[++cnt] = newpoint;
	}
	for (int i = 1; i <= n; i++)	ans = max(ans, f[i]);
	cout << ans;
	//cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}


#include<bits/stdc++.h>

#define pb push_back
#define fi first
#define se second
#define LL long long
#define debug(x) cerr << #x << " = " << (x) << " ";

using namespace std;

typedef pair<LL, LL> ii;
typedef pair<int, ii> pii;
typedef vector<int> vi;
typedef vector<ii> vii;

const LL oo = 1e17 + 7;
const int maxN = 1e6 + 7;

struct MODE
{
	LL X, Y, A;
} rec[maxN];

LL n, it, cnt, X[maxN], Y[maxN], a[maxN], f[maxN];
ii point[maxN];

long long readInt () {
	bool minus = false;
	long long result = 0;
	char ch;
	ch = getchar();
	while (true) {
		if (ch == '-') break;
		if (ch >= '0' && ch <= '9') break;
		ch = getchar();
	}
	if (ch == '-') minus = true; else result = ch-'0';
	while (true) {
		ch = getchar();
		if (ch < '0' || ch > '9') break;
		result = result*10 + (ch - '0');
	}
	if (minus)
		return -result;
	else
		return result;
}

bool cmp(MODE A, MODE B)
{
	return A.X < B.X;
}

bool bad(ii A, ii B, ii C)
{
	return 1.0 * (C.se - A.se) * (A.fi - B.fi) <= 1.0 * (B.se - A.se) * (A.fi - C.fi);
}

LL get(int X)
{
	if (it >= cnt)	it = cnt;
	while (it + 1 <= cnt && point[it + 1].fi * X + point[it + 1].se >= point[it].fi * X + point[it].se)	it++;
	return point[it].fi * X + point[it].se;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	n = readInt();
	for (int i = 1; i <= n; i++)
	{
		rec[i].X = readInt();
		rec[i].Y = readInt();
		rec[i].A = readInt();
	}
	sort(rec + 1, rec + n + 1, cmp);
	cnt = 0; it = 1;
	LL ans = -oo;
	for (int i = 1; i <= n; i++)
	{
		f[i] = rec[i].X * rec[i].Y - rec[i].A;
		f[i] = max(f[i], get(-rec[i].Y) + rec[i].X * rec[i].Y - rec[i].A);
		ii newpoint = ii(rec[i].X, f[i]);
		while (cnt >= 2 && bad(point[cnt - 1], point[cnt], newpoint))	cnt--;
		point[++cnt] = newpoint;
	}
	for (int i = 1; i <= n; i++)	ans = max(ans, f[i]);
	cout << ans;
	//cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}


#include<bits/stdc++.h>

#define pb push_back
#define fi first
#define se second
#define LL long long
#define debug(x) cerr << #x << " = " << (x) << " ";

using namespace std;

typedef pair<LL, LL> ii;
typedef pair<int, ii> pii;
typedef vector<int> vi;
typedef vector<ii> vii;

const LL oo = 1e17 + 7;
const int maxN = 1e6 + 7;

struct MODE
{
	LL X, Y, A;
} rec[maxN];

LL n, it, cnt, X[maxN], Y[maxN], a[maxN], f[maxN];
ii point[maxN];

long long readInt () {
	bool minus = false;
	long long result = 0;
	char ch;
	ch = getchar();
	while (true) {
		if (ch == '-') break;
		if (ch >= '0' && ch <= '9') break;
		ch = getchar();
	}
	if (ch == '-') minus = true; else result = ch-'0';
	while (true) {
		ch = getchar();
		if (ch < '0' || ch > '9') break;
		result = result*10 + (ch - '0');
	}
	if (minus)
		return -result;
	else
		return result;
}

bool cmp(MODE A, MODE B)
{
	return A.X < B.X;
}

bool bad(ii A, ii B, ii C)
{
	return 1.0 * (C.se - A.se) * (A.fi - B.fi) <= 1.0 * (B.se - A.se) * (A.fi - C.fi);
}

LL get(LL X)
{
	if (it >= cnt)	it = cnt;
	while (it + 1 <= cnt && point[it + 1].fi * X + point[it + 1].se <= point[it].fi * X + point[it].se)	it++;
	if (it == 0)	return 0;
	return point[it].fi * X + point[it].se;
}

// LL Get(ii d, LL X)
// {
// 	return d.fi * X + d.se;
// }

// LL Query(LL X)
// {
// 	int l = 0, r = cnt + 1;
// 	LL cur = -oo;
// 	while (r - l > 2)
// 	{
// 		int m1 = (l + l + r) / 3;	int m2 = (l + r + r) / 3;
// 		if (Get(point[m1], X) == Get(point[m2], X))	l = m1, r = m2;
// 		else
// 		if (Get(point[m1], X) < Get(point[m2],X))	l = m1;
// 		else	r = m2;
// 	}
// 	if (l == 0)	l = 1;	if (r >= cnt)	r = cnt;
// 	for (int i = l; i <= r; i++)
// 		cur = max(cur, Get(point[i], X));
// 	return cur;
// }

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	n = readInt();
	for (int i = 1; i <= n; i++)
	{
		rec[i].X = readInt();
		rec[i].Y = readInt();
		rec[i].A = readInt();
	}
	sort(rec + 1, rec + n + 1, cmp);
	cnt = 0;	it = 1;
	LL ans = -oo;
	for (int i = 1; i <= n; i++)
	{
		f[i] = rec[i].X * rec[i].Y - rec[i].A;
		f[i] = max(f[i], -get(-rec[i].Y) + rec[i].X * rec[i].Y - rec[i].A);
		ii newpoint = ii(-rec[i].X, -f[i]);
		while (cnt >= 2 && bad(point[cnt - 1], point[cnt], newpoint))	cnt--;
		point[++cnt] = newpoint;
	}
	for (int i = 1; i <= n; i++)	ans = max(ans, f[i]);
	cout << ans;
	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}


#include<bits/stdc++.h>

#define pb push_back
#define fi first
#define se second
#define LL long long
#define debug(x) cerr << #x << " = " << (x) << " ";

using namespace std;

typedef pair<LL, LL> ii;
typedef pair<int, ii> pii;
typedef vector<int> vi;
typedef vector<ii> vii;

const LL oo = 1e18 + 7;
const int maxN = 1e6 + 7;

struct MODE
{
	LL X, Y, A;
} rec[maxN];

LL n, it, cnt, X[maxN], Y[maxN], a[maxN], f[maxN];
ii point[maxN];

long long readInt () {
	bool minus = false;
	long long result = 0;
	char ch;
	ch = getchar();
	while (true) {
		if (ch == '-') break;
		if (ch >= '0' && ch <= '9') break;
		ch = getchar();
	}
	if (ch == '-') minus = true; else result = ch-'0';
	while (true) {
		ch = getchar();
		if (ch < '0' || ch > '9') break;
		result = result*10 + (ch - '0');
	}
	if (minus)
		return -result;
	else
		return result;
}

bool cmp(MODE A, MODE B)
{
	return A.X < B.X;
}

bool bad(ii A, ii B, ii C)
{
	return 1.0 * (C.se - A.se) * (A.fi - B.fi) <= 1.0 * (B.se - A.se) * (A.fi - C.fi);
}

LL get(int X)
{
	if (it >= cnt)	it = cnt;
	while (it + 1 <= cnt && point[it + 1].fi * X + point[it + 1].se >= point[it].fi * X + point[it].se)	it++;
	return point[it].fi * X + point[it].se;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	n = readInt();
	for (int i = 1; i <= n; i++)
	{
		rec[i].X = readInt();
		rec[i].Y = readInt();
		rec[i].A = readInt();
	}
	sort(rec + 1, rec + n + 1, cmp);
	cnt = 0; it = 1;
	LL ans = -oo;
	for (int i = 1; i <= n; i++)
	{
		f[i] = rec[i].X * rec[i].Y - rec[i].A;
		f[i] = get(rec[i].Y) + rec[i].X * rec[i].Y - rec[i].A;
		ii newpoint = ii(-rec[i].X, f[i]);
		while (cnt >= 2 && bad(point[cnt - 1], point[cnt], newpoint))	cnt--;
		point[++cnt] = newpoint;
	}
	for (int i = 1; i <= n; i++)	ans = max(ans, f[i]);
	cout << ans;
	//cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}


#include<bits/stdc++.h>

#define pb push_back
#define fi first
#define se second
#define LL long long
#define debug(x) cerr << #x << " = " << (x) << " ";

using namespace std;

typedef pair<int, int> ii;
typedef pair<int, ii> pii;
typedef vector<int> vi;
typedef vector<ii> vii;

const LL oo = 1e17 + 7;
const int maxN = 1e6 + 7;

struct MODE
{
	LL X, Y, A;
} rec[maxN];

LL n, it, cnt, X[maxN], Y[maxN], a[maxN], f[maxN];
ii point[maxN];

int readInt () {
	bool minus = false;
	int result = 0;
	char ch;
	ch = getchar();
	while (true) {
		if (ch == '-') break;
		if (ch >= '0' && ch <= '9') break;
		ch = getchar();
	}
	if (ch == '-') minus = true; else result = ch-'0';
	while (true) {
		ch = getchar();
		if (ch < '0' || ch > '9') break;
		result = result*10 + (ch - '0');
	}
	if (minus)
		return -result;
	else
		return result;
}

bool cmp(MODE A, MODE B)
{
	return A.X < B.X;
}

bool bad(ii A, ii B, ii C)
{
	return 1.0 * (C.se - A.se) * (A.fi - B.fi) <= 1.0 * (B.se - A.se) * (A.fi - C.fi);
}

int get(int X)
{
	if (it >= cnt)	it = cnt;
	while (it + 1 <= cnt && point[it + 1].fi * X + point[it + 1].se >= point[it].fi * X + point[it].se)	it++;
	return point[it].fi * X + point[it].se;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	n = readInt();
	for (int i = 1; i <= n; i++)
	{
		rec[i].X = readInt();
		rec[i].Y = readInt();
		rec[i].A = readInt();
	}
	sort(rec + 1, rec + n + 1, cmp);
	cnt = 0; it = 1;
	LL ans = -oo;
	for (int i = 1; i <= n; i++)
	{
		f[i] = rec[i].X * rec[i].Y - rec[i].A;
		f[i] = get(rec[i].Y) + rec[i].X * rec[i].Y - rec[i].A;
		ii newpoint = ii(-rec[i].X, f[i]);
		while (cnt >= 2 && bad(point[cnt - 1], point[cnt], newpoint))	cnt--;
		point[++cnt] = newpoint;
	}
	for (int i = 1; i <= n; i++)	ans = max(ans, f[i]);
	cout << ans;
	//cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int N = 1e6 + 111;

int n;
int x[N], y[N];
ll a[N];
int p[N];

struct DynamicConvexHullTrickLine {
	long long a, b;
	mutable set<DynamicConvexHullTrickLine>::iterator prev, next;
	const set<DynamicConvexHullTrickLine>* root;

	bool operator<(const DynamicConvexHullTrickLine& line) const {
		if (line.root != nullptr)
			return a < line.a;
		if (root == nullptr || next == root->end())
			return false;
		return b - next->b < line.a * (next->a - a);
	}
};

#include <bits/stdc++.h>
using namespace std;

struct DynamicConvexHullTrickLine {
	long long a, b;
	mutable set<DynamicConvexHullTrickLine>::iterator prev, next;
	const set<DynamicConvexHullTrickLine>* root;

	bool operator<(const DynamicConvexHullTrickLine& line) const {
		if (line.root != nullptr)
			return a < line.a;
		if (root == nullptr || next == root->end())
			return false;
		return b - next->b < line.a * (next->a - a);
	}
};

class DynamicConvexHullTrick : private set<DynamicConvexHullTrickLine> {
private:
	typedef DynamicConvexHullTrickLine Line;

	bool isBad(iterator curr) {
		iterator prev = curr->prev, next = curr->next;
		if (prev == end() || next == end())
			return false;
		const DynamicConvexHullTrickLine& p = *prev, c = *curr, n = *next;
		return (c.b - n.b) * (long double)(c.a - p.a)
			<= (p.b - c.b) * (long double)(n.a - c.a);
	}

	void removeLine(iterator curr) {
		iterator prev = curr->prev, next = curr->next;
		if (prev != end())
			prev->next = curr->next;
		if (next != end())
			next->prev = curr->prev;
		erase(curr);
	}

public:
	DynamicConvexHullTrick() {}

	void add(long long a, long long b) {
		Line line = (Line){a, b, end(), end(), this};
		iterator curr = find(line);
		if (curr != end()) {
			if (b <= curr->b)
				return;
			removeLine(curr);
		}
		curr = insert(line).first;
		iterator prev = curr, next = curr;
		if (++next != end())
			curr->next = next, next->prev = curr;
		if (prev-- != begin())
			curr->prev = prev, prev->next = curr;
		if (isBad(curr)) {
			removeLine(curr);
			return;
		}
		while (curr->next != end() && isBad(curr->next))
			removeLine(curr->next);
		while (curr->prev != end() && isBad(curr->prev))
			removeLine(curr->prev);
	}

	long long get(long long x) const {
		Line query = (Line){x, 0, end(), end(), nullptr};
		Line line = *lower_bound(query);
		return line.a * x + line.b;
	}

	void clear() {
		clear();
	}
};

bool comp(int lhs, int rhs) {
	// if (y[lhs] != y[rhs])
	// 	return y[lhs] > y[rhs];
	return x[lhs] < x[rhs];
}

int main() {
#ifdef LOCAL_TESTING
	freopen("input.txt", "rt", stdin);
//	freopen("output.txt", "wt", stdout);
#endif
	// ...

	scanf("%d", &n);

	for (int i = 0; i < n; i++)
		scanf("%d%d%lld", x + i, y + i, a + i);

	for (int i = 0; i < n; i++)
		p[i] = i;

	sort(p, p + n, comp);

	DynamicConvexHullTrick cht;
	cht.add(0, 0);

	ll ans = 0;

	for (int i_ = 0; i_ < n; i_++) {
		int i = p[i_];
		ll ci = cht.get(y[i]) + ll(y[i]) * x[i] - a[i];
		ans = max(ans, ci);
		cht.add(-x[i], ci);
	}

	cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int N = 1e6 + 111;

int n;
int x[N], y[N];
ll a[N];
int p[N];

class DynamicConvexHullTrick {
private:
	struct Line {
		long long a, b;
		bool isQuery;
		mutable set<Line>::iterator prev, next;
		const set<Line>* root;

		bool operator<(const Line &line) const {
			if (!line.isQuery)
				return a < line.a;
			if (next == root->end())
				return false;
			return b - next->b < line.a * (next->a - a);
		}
	};

	set<Line> hull;

	bool isBad(set<Line>::iterator curr) {
		set<Line>::iterator prev = curr->prev, next = curr->next;
		if (prev == hull.end() || next == hull.end())
			return false;
		const Line& p = *prev, c = *curr, n = *next;
		return (c.b - n.b) * (c.a - p.a) <= (p.b - c.b) * (n.a - c.a);
	}

	void removeLine(set<Line>::iterator curr) {
		set<Line>::iterator prev = curr->prev, next = curr->next;
		if (prev != hull.end())
			prev->next = curr->next;
		if (next != hull.end())
			next->prev = curr->prev;
		hull.erase(curr);
	}

public:
	DynamicConvexHullTrick() : hull() {}

	void add(long long a, long long b) {
		Line line = (Line){a, b, false, hull.end(), hull.end(), &hull};
		set<Line>::iterator curr = hull.find(line);
		if (curr != hull.end()) {
			if (b <= curr->b)
				return;
			removeLine(curr);
		}
		curr = hull.insert(line).first;
		set<Line>::iterator prev = curr, next = curr;
		if (++next != hull.end())
			curr->next = next, next->prev = curr;
		if (prev-- != hull.begin())
			curr->prev = prev, prev->next = curr;
		if (isBad(curr)) {
			removeLine(curr);
			return;
		}
		while (curr->next != hull.end() && isBad(curr->next))
			removeLine(curr->next);
		while (curr->prev != hull.end() && isBad(curr->prev))
			removeLine(curr->prev);
	}

	long long get(long long x) const {
		Line query = (Line){x, 0, true, hull.end(), hull.end(), &hull};
		Line line = *hull.lower_bound(query);
		return line.a * x + line.b;
	}

	void clear() {
		hull.clear();
	}
};

bool comp(int lhs, int rhs) {
	return ll(x[lhs] * y[lhs]) < ll(x[rhs] * y[rhs]);
}

int main() {
#ifdef LOCAL_TESTING
	freopen("input.txt", "rt", stdin);
//	freopen("output.txt", "wt", stdout);
#endif
	// ...

	scanf("%d", &n);

	for (int i = 0; i < n; i++)
		scanf("%d%d%lld", x + i, y + i, a + i);

	for (int i = 0; i < n; i++)
		p[i] = i;

	sort(p, p + n, comp);

	DynamicConvexHullTrick cht;
	cht.add(0, 0);

	ll ans = 0;

	for (int i_ = 0; i_ < n; i_++) {
		int i = p[i_];
		ll ci = cht.get(y[i]) + ll(y[i]) * x[i] - a[i];
		ans = max(ans, ci);
		cht.add(-x[i], ci);
	}

	cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int N = 1e6 + 111;

int n;
int x[N], y[N];
ll a[N];
int p[N];

struct DynamicConvexHullTrickLine {
	long long a, b;
	mutable set<DynamicConvexHullTrickLine>::iterator prev, next;
	const set<DynamicConvexHullTrickLine>* root;

	bool operator<(const DynamicConvexHullTrickLine& line) const {
		if (line.root != nullptr)
			return a < line.a;
		if (root == nullptr || next == root->end())
			return false;
		return b - next->b < line.a * (next->a - a);
	}
};

class DynamicConvexHullTrick : private set<DynamicConvexHullTrickLine> {
private:
	typedef DynamicConvexHullTrickLine Line;

	bool isBad(iterator curr) {
		iterator prev = curr->prev, next = curr->next;
		if (prev == end() || next == end())
			return false;
		const DynamicConvexHullTrickLine& p = *prev, c = *curr, n = *next;
		return (c.b - n.b) * (c.a - p.a) <= (p.b - c.b) * (n.a - c.a);
	}

	void removeLine(iterator curr) {
		iterator prev = curr->prev, next = curr->next;
		if (prev != end())
			prev->next = curr->next;
		if (next != end())
			next->prev = curr->prev;
		erase(curr);
	}

public:
	DynamicConvexHullTrick() {}

	void add(long long a, long long b) {
		Line line = (Line){a, b, end(), end(), this};
		iterator curr = find(line);
		if (curr != end()) {
			if (b <= curr->b)
				return;
			removeLine(curr);
		}
		curr = insert(line).first;
		iterator prev = curr, next = curr;
		if (++next != end())
			curr->next = next, next->prev = curr;
		if (prev-- != begin())
			curr->prev = prev, prev->next = curr;
		if (isBad(curr)) {
			removeLine(curr);
			return;
		}
		while (curr->next != end() && isBad(curr->next))
			removeLine(curr->next);
		while (curr->prev != end() && isBad(curr->prev))
			removeLine(curr->prev);
	}

	long long get(long long x) const {
		Line query = (Line){x, 0, end(), end(), nullptr};
		Line line = *lower_bound(query);
		return line.a * x + line.b;
	}

	void clear() {
		clear();
	}
};

bool comp(int lhs, int rhs) {
	// if (y[lhs] != y[rhs])
	// 	return y[lhs] > y[rhs];
	return x[lhs] < x[rhs];
}

int main() {
#ifdef LOCAL_TESTING
	freopen("input.txt", "rt", stdin);
//	freopen("output.txt", "wt", stdout);
#endif
	// ...

	scanf("%d", &n);

	for (int i = 0; i < n; i++)
		scanf("%d%d%lld", x + i, y + i, a + i);

	for (int i = 0; i < n; i++)
		p[i] = i;

	sort(p, p + n, comp);

	DynamicConvexHullTrick cht;
	cht.add(0, 0);

	ll ans = 0;

	for (int i_ = 0; i_ < n; i_++) {
		int i = p[i_];
		ll ci = cht.get(y[i]) + ll(y[i]) * x[i] - a[i];
		ans = max(ans, ci);
		cht.add(-x[i], ci);
	}

	cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int N = 1e6 + 111;

int n;
int x[N], y[N];
ll a[N];
int p[N];

class DynamicConvexHullTrick {
private:
	struct Line {
		long long a, b;
		bool isQuery;
		mutable set<Line>::iterator prev, next;
		const set<Line>* root;

		bool operator<(const Line &line) const {
			if (!line.isQuery)
				return a < line.a;
			if (next == root->end())
				return false;
			return b - next->b < line.a * (next->a - a);
		}
	};

	set<Line> hull;

	bool isBad(set<Line>::iterator curr) {
		set<Line>::iterator prev = curr->prev, next = curr->next;
		if (prev == hull.end() || next == hull.end())
			return false;
		const Line& p = *prev, c = *curr, n = *next;
		return (c.b - n.b) * (c.a - p.a) <= (p.b - c.b) * (n.a - c.a);
	}

	void removeLine(set<Line>::iterator curr) {
		set<Line>::iterator prev = curr->prev, next = curr->next;
		if (prev != hull.end())
			prev->next = curr->next;
		if (next != hull.end())
			next->prev = curr->prev;
		hull.erase(curr);
	}

public:
	DynamicConvexHullTrick() : hull() {}

	void add(long long a, long long b) {
		Line line = (Line){a, b, false, hull.end(), hull.end(), &hull};
		set<Line>::iterator curr = hull.find(line);
		if (curr != hull.end()) {
			if (b <= curr->b)
				return;
			removeLine(curr);
		}
		curr = hull.insert(line).first;
		set<Line>::iterator prev = curr, next = curr;
		if (++next != hull.end())
			curr->next = next, next->prev = curr;
		if (prev-- != hull.begin())
			curr->prev = prev, prev->next = curr;
		if (isBad(curr)) {
			removeLine(curr);
			return;
		}
		while (curr->next != hull.end() && isBad(curr->next))
			removeLine(curr->next);
		while (curr->prev != hull.end() && isBad(curr->prev))
			removeLine(curr->prev);
	}

	long long get(long long x) const {
		Line query = (Line){x, 0, true, hull.end(), hull.end(), &hull};
		Line line = *hull.lower_bound(query);
		return line.a * x + line.b;
	}

	void clear() {
		hull.clear();
	}
};

bool comp(int lhs, int rhs) {
	// if (y[lhs] != y[rhs])
	// 	return y[lhs] > y[rhs];
	return x[lhs] < x[rhs];
}

int main() {
#ifdef LOCAL_TESTING
	freopen("input.txt", "rt", stdin);
//	freopen("output.txt", "wt", stdout);
#endif
	// ...

	cin >> n;

	for (int i = 0; i < n; i++)
		cin >> x[i] >> y[i] >> a[i];

	for (int i = 0; i < n; i++)
		p[i] = i;

	sort(p, p + n, comp);

	DynamicConvexHullTrick cht;
	cht.add(0, 0);

	ll ans = 0;

	for (int i_ = 0; i_ < n; i_++) {
		int i = p[i_];
		ll ci = cht.get(y[i]) + ll(y[i]) * x[i] - a[i];
		ans = max(ans, ci);
		cht.add(-x[i], ci);
	}

	cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int N = 1e6 + 111;

int n;
int x[N], y[N];
ll a[N];
int p[N];

struct DynamicConvexHullTrickLine {
	long long a, b;
	mutable set<DynamicConvexHullTrickLine>::iterator prev, next;
	const set<DynamicConvexHullTrickLine>* root;

	bool operator<(const DynamicConvexHullTrickLine& line) const {
		if (line.root != nullptr)
			return a < line.a;
		if (root == nullptr || next == root->end())
			return false;
		return b - next->b < line.a * (next->a - a);
	}
};

class DynamicConvexHullTrick : private set<DynamicConvexHullTrickLine> {
private:
	typedef DynamicConvexHullTrickLine Line;

	bool isBad(iterator curr) {
		iterator prev = curr->prev, next = curr->next;
		if (prev == end() || next == end())
			return false;
		const DynamicConvexHullTrickLine& p = *prev, c = *curr, n = *next;
		return (c.b - n.b) * (long double)(c.a - p.a)
			<= (p.b - c.b) * (long double)(n.a - c.a);
	}

	void removeLine(iterator curr) {
		iterator prev = curr->prev, next = curr->next;
		if (prev != end())
			prev->next = curr->next;
		if (next != end())
			next->prev = curr->prev;
		erase(curr);
	}

public:
	DynamicConvexHullTrick() {}

	void add(long long a, long long b) {
		Line line = (Line){a, b, end(), end(), this};
		iterator curr = find(line);
		if (curr != end()) {
			if (b <= curr->b)
				return;
			removeLine(curr);
		}
		curr = insert(line).first;
		iterator prev = curr, next = curr;
		if (++next != end())
			curr->next = next, next->prev = curr;
		if (prev-- != begin())
			curr->prev = prev, prev->next = curr;
		if (isBad(curr)) {
			removeLine(curr);
			return;
		}
		while (curr->next != end() && isBad(curr->next))
			removeLine(curr->next);
		while (curr->prev != end() && isBad(curr->prev))
			removeLine(curr->prev);
	}

	long long get(long long x) const {
		Line query = (Line){x, 0, end(), end(), nullptr};
		Line line = *lower_bound(query);
		return line.a * x + line.b;
	}

	void clear() {
		clear();
	}
};

bool comp(int lhs, int rhs) {
	// if (y[lhs] != y[rhs])
	// 	return y[lhs] > y[rhs];
	return x[lhs] < x[rhs];
}

int main() {
#ifdef LOCAL_TESTING
	freopen("input.txt", "rt", stdin);
//	freopen("output.txt", "wt", stdout);
#endif
	// ...

	scanf("%d", &n);

	for (int i = 0; i < n; i++)
		scanf("%d%d%lld", x + i, y + i, a + i);

	for (int i = 0; i < n; i++)
		p[i] = i;

	sort(p, p + n, comp);

	DynamicConvexHullTrick cht;
	cht.add(0, 0);

	ll ans = 0;

	for (int i_ = 0; i_ < n; i_++) {
		int i = p[i_];
		ll ci = cht.get(y[i]) + ll(y[i]) * x[i] - a[i];
		ans = max(ans, ci);
		cht.add(-x[i], ci);
	}

	cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int N = 1e6 + 111;

int n;
int x[N], y[N];
ll a[N];
int p[N];

class DynamicConvexHullTrick {
private:
	struct Line {
		long long a, b;
		bool isQuery;
		mutable set<Line>::iterator prev, next;
		const set<Line>* root;

		bool operator<(const Line &line) const {
			if (!line.isQuery)
				return a < line.a;
			if (next == root->end())
				return false;
			return b - next->b < line.a * (next->a - a);
		}
	};

	set<Line> hull;

	bool isBad(set<Line>::iterator curr) {
		set<Line>::iterator prev = curr->prev, next = curr->next;
		if (prev == hull.end() || next == hull.end())
			return false;
		const Line& p = *prev, c = *curr, n = *next;
		return (c.b - n.b) * (c.a - p.a) <= (p.b - c.b) * (n.a - c.a);
	}

	void removeLine(set<Line>::iterator curr) {
		set<Line>::iterator prev = curr->prev, next = curr->next;
		if (prev != hull.end())
			prev->next = curr->next;
		if (next != hull.end())
			next->prev = curr->prev;
		hull.erase(curr);
	}

public:
	DynamicConvexHullTrick() : hull() {}

	void add(long long a, long long b) {
		Line line = (Line){a, b, false, hull.end(), hull.end(), &hull};
		set<Line>::iterator curr = hull.find(line);
		if (curr != hull.end()) {
			if (b <= curr->b)
				return;
			removeLine(curr);
		}
		curr = hull.insert(line).first;
		set<Line>::iterator prev = curr, next = curr;
		if (++next != hull.end())
			curr->next = next, next->prev = curr;
		if (prev-- != hull.begin())
			curr->prev = prev, prev->next = curr;
		if (isBad(curr)) {
			removeLine(curr);
			return;
		}
		while (curr->next != hull.end() && isBad(curr->next))
			removeLine(curr->next);
		while (curr->prev != hull.end() && isBad(curr->prev))
			removeLine(curr->prev);
	}

	long long get(long long x) const {
		Line query = (Line){x, 0, true, hull.end(), hull.end(), &hull};
		Line line = *hull.lower_bound(query);
		return line.a * x + line.b;
	}

	void clear() {
		hull.clear();
	}
};

bool comp(int l, int r) {
	return ll(x[l]) * y[l] - a[l] < ll(x[r]) * y[r];
}

int main() {
#ifdef LOCAL_TESTING
	freopen("input.txt", "rt", stdin);
//	freopen("output.txt", "wt", stdout);
#endif
	// ...

	scanf("%d", &n);

	for (int i = 0; i < n; i++)
		scanf("%d%d%lld", x + i, y + i, a + i);

	for (int i = 0; i < n; i++)
		p[i] = i;

	sort(p, p + n, comp);

	DynamicConvexHullTrick cht;
	cht.add(0, 0);

	ll ans = 0;

	for (int i_ = 0; i_ < n; i_++) {
		int i = p[i_];
		ll ci = cht.get(y[i]) + ll(y[i]) * x[i] - a[i];
		ans = max(ans, ci);
		cht.add(-x[i], ci);
	}

	cout << ans << endl;

	return 0;
}