#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 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 : public set<DynamicConvexHullTrickLine> {
private:
	typedef DynamicConvexHullTrickLine Line;

	bool isBad(iterator curr) {
		iterator prev = curr, next = curr->next;
		if (next == end())
			return false;
		const Line& 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, next = curr->next;
		if (prev != begin())
			(--prev)->next = curr->next;
		erase(curr);
	}

public:
	DynamicConvexHullTrick() {}

	void add(long long a, long long b) {
		Line line = (Line){a, b, 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;
		if (prev != begin()) {
			if (isBad(curr)) {
				removeLine(curr);
				return;
			}
			(--prev)->next = curr;
		}
		while (curr->next != end() && isBad(curr->next))
			removeLine(curr->next);
		while (prev-- != begin() && isBad(prev->next))
			removeLine(prev->next);
	}

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

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;
		mutable set<Line>::iterator prev, next;
		const set<Line>* root;

		bool operator<(const Line &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);
		}
	};

	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 (long double)(c.b - n.b) * (c.a - p.a) <= (long double)(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, 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, hull.end(), hull.end(), nullptr};
		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
	// ...

	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 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 : public set<DynamicConvexHullTrickLine> {
private:
	typedef DynamicConvexHullTrickLine Line;

	bool isBad(iterator curr) {
		iterator prev = curr, next = curr->next;
		if (next == end())
			return false;
		const Line& 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, next = curr->next;
		if (prev != begin())
			(--prev)->next = curr->next;
		erase(curr);
	}

public:
	DynamicConvexHullTrick() {}

	void add(long long a, long long b) {
		Line line = (Line){a, b, 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;
		if (prev != begin()) {
			if (isBad(curr)) {
				removeLine(curr);
				return;
			}
			(--prev)->next = curr;
		}
		while (curr->next != end() && isBad(curr->next))
			removeLine(curr->next);
		while (prev-- != begin() && isBad(prev->next))
			removeLine(prev->next);
	}

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

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[r] < ll(x[r]) * y[l];
}

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 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 : public set<DynamicConvexHullTrickLine> {
private:
	typedef DynamicConvexHullTrickLine Line;

	bool isBad(iterator curr) {
		iterator prev = curr, next = curr->next;
		if (next == end())
			return false;
		--prev;
		const Line& 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, next = curr->next;
		if (prev != begin())
			(--prev)->next = curr->next;
		erase(curr);
	}

public:
	DynamicConvexHullTrick() {}

	void add(long long a, long long b) {
		Line line = (Line){a, b, 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;
		if (prev != begin()) {
			if (isBad(curr)) {
				removeLine(curr);
				return;
			}
			(--prev)->next = curr;
		}
		while (curr->next != end() && isBad(curr->next))
			removeLine(curr->next);
		while (prev-- != begin() && isBad(prev->next))
			removeLine(prev->next);
	}

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

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];

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 (long double)(c.b - n.b) * (c.a - p.a) <= (long double)(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
	// ...

	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
	// ...

	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;
		mutable set<Line>::iterator next;
		const set<Line>* root;

		bool operator<(const Line& 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);
		}
	};

	set<Line> hull;

	bool isBad(set<Line>::iterator curr) {
		set<Line>::iterator prev = curr, next = curr->next;
		if (next == hull.end())
			return false;
		const Line& 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(set<Line>::iterator curr) {
		set<Line>::iterator prev = curr, next = curr->next;
		if (prev != hull.begin())
			(--prev)->next = curr->next;
		hull.erase(curr);
	}

public:
	DynamicConvexHullTrick() {}

	void add(long long a, long long b) {
		Line line = (Line){a, b, 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;
		if (prev != hull.begin()) {
			if (isBad(curr)) {
				removeLine(curr);
				return;
			}
			(--prev)->next = curr;
		}
		while (curr->next != hull.end() && isBad(curr->next))
			removeLine(curr->next);
		while (prev-- != hull.begin() && isBad(prev->next))
			removeLine(prev->next);
	}

	long long get(long long x) const {
		Line query = (Line){x, 0, hull.end(), nullptr};
		const 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
	// ...

	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;
}


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

		bool operator<(const Line& 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);
		}
	};

	set<Line> hull;

	bool isBad(set<Line>::iterator curr) {
		set<Line>::iterator prev = curr, next = curr->next;
		if (next == hull.end())
			return false;
		const Line& 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(set<Line>::iterator curr) {
		set<Line>::iterator prev = curr, next = curr->next;
		if (prev != hull.begin())
			(--prev)->next = curr->next;
		hull.erase(curr);
	}

public:
	DynamicConvexHullTrick() {}

	void add(long long a, long long b) {
		Line line = (Line){a, b, 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;
		if (prev != hull.begin()) {
			if (isBad(curr)) {
				removeLine(curr);
				return;
			}
			(--prev)->next = curr;
		}
		while (curr->next != hull.end() && isBad(curr->next))
			removeLine(curr->next);
		while (prev-- != hull.begin() && isBad(prev->next))
			removeLine(prev->next);
	}

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

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


#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[r] < ll(x[r]) * y[l];
}

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);
	}

	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 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 : public set<DynamicConvexHullTrickLine> {
private:
	typedef DynamicConvexHullTrickLine Line;

	bool isBad(iterator curr) {
		iterator prev = curr, next = curr->next;
		if (next == end())
			return false;
		--prev;
		const Line& 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);
	}

public:
	DynamicConvexHullTrick() {}

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

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

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];

struct DynamicConvexHullTrickLine {
	long long a, b;
	mutable set<DynamicConvexHullTrickLine>::iterator 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 : public set<DynamicConvexHullTrickLine> {
private:
	typedef DynamicConvexHullTrickLine Line;

	bool isBad(iterator prev, iterator curr) {
		iterator next = curr->next;
		if (next == end())
			return false;
		const Line& 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, next = curr->next;
		if (prev != begin())
			(--prev)->next = curr->next;
		erase(curr);
	}

public:
	DynamicConvexHullTrick() {}

	void add(long long a, long long b) {
		Line line = (Line){a, b, 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;
		if (prev != begin()) {
			(--prev)->next = curr;
			if (isBad(prev, curr)) {
				removeLine(curr);
				return;
			}
		}
		while (curr->next != end() && isBad(curr, curr->next))
			removeLine(curr->next);
		while (prev-- != begin() && isBad(prev, prev->next))
			removeLine(prev->next);
	}

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

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
	// ...

	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;
		mutable set<Line>::iterator next;
		const set<Line>* root;

		bool operator<(const Line& 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);
		}
	};

	set<Line> hull;

	bool isBad(set<Line>::iterator curr) {
		set<Line>::iterator prev = curr, next = curr->next;
		if (next == hull.end())
			return false;
		const Line& 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(set<Line>::iterator curr) {
		set<Line>::iterator prev = curr, next = curr->next;
		if (prev != hull.begin())
			(--prev)->next = curr->next;
		hull.erase(curr);
	}

public:
	DynamicConvexHullTrick() {}

	void add(long long a, long long b) {
		Line line = (Line){a, b, hull.end(), this};
		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;
		if (prev != hull.begin()) {
			if (isBad(curr)) {
				removeLine(curr);
				return;
			}
			(--prev)->next = curr;
		}
		while (curr->next != hull.end() && isBad(curr->next))
			removeLine(curr->next);
		while (prev-- != hull.begin() && isBad(prev->next))
			removeLine(prev->next);
	}

	long long get(long long x) const {
		Line query = (Line){x, 0, hull.end(), nullptr};
		const 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
	// ...

	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 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 : public set<DynamicConvexHullTrickLine> {
private:
	typedef DynamicConvexHullTrickLine Line;

	bool isBad(iterator curr) {
		iterator prev = curr, next = curr->next;
		if (next == end())
			return false;
		--prev;
		const Line& 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, next = curr->next;
		if (prev != begin())
			(--prev)->next = curr->next;
		erase(curr);
	}

public:
	DynamicConvexHullTrick() {}

	void add(long long a, long long b) {
		Line line = (Line){a, b, 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;
		if (prev != begin()) {
			if (isBad(curr)) {
				removeLine(curr);
				return;
			}
			(--prev)->next = curr;
		}
		while (curr->next != end() && isBad(curr->next))
			removeLine(curr->next);
		while (prev-- != begin() && isBad(prev->next))
			removeLine(prev->next);
	}

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

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];

struct DynamicConvexHullTrickLine {
	long long a, b;
	mutable set<DynamicConvexHullTrickLine>::iterator 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 : public set<DynamicConvexHullTrickLine> {
private:
	typedef DynamicConvexHullTrickLine Line;

	bool isBad(iterator curr) {
		iterator prev = curr, next = curr->next;
		const Line& 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, next = curr->next;
		if (prev-- != begin())
			prev->next = curr->next;
		erase(curr);
	}

public:
	DynamicConvexHullTrick() {}

	void add(long long a, long long b) {
		Line line = (Line){a, b, 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;
		if (prev-- != begin()) {
			if (next != end() && isBad(curr)) {
				removeLine(curr);
				return;
			}
			prev->next = curr;
		}
		while (curr->next != end() && isBad(curr->next))
			removeLine(curr->next);
		while (prev-- != begin() && isBad(prev->next))
			removeLine(prev->next);
	}

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

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;

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

#define bug(...)                                  __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{	rtn
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

inline void INP();
const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q;

// :: convex_hull_trick ::
#define ll long long
struct line { ll m, c; };

ll divide(ll a, ll b) { return a / b - ( (a ^ b) < 0 and (a % b) );}
ll intersectX(line &l1, line &l2) {
	if (l1.m == l2.m) return -(ll)1e16;
	return divide(l1.c - l2.c, l2.m - l1.m);
}

vector<ll> points;
deque<line> st;

void add_line(line nline) {
	if ( st.size() == 0 ) st.pb(nline);
	else if ( st.size() == 1 ) points.pb( intersectX(nline, st.back()) ), st.pb(nline);
	else
	{
		while ( st.size() and intersectX(nline, st.back()) <= points.back() ) {
			st.pop_back();
			points.pop_back();
		}
		if ( st.size() ) points.pb( intersectX(nline, st.back()) );
		st.pb(nline);
	}
}

ll find_best(int x) {
	int id = lower_bound( all(points), (ll)x ) - points.begin();
	return st[id].m * x + st[id].c;
}

int brr[N];
struct rec
{
	int x, y, a;
};

rec arr[N];
ll dp[N];

void solve()
{
	cin >> n;
	lop(i, 1, n + 1) cin >> arr[i].x >> arr[i].y >> arr[i].a;

	sort(arr + 1, arr + n + 1, [&](rec & a, rec & b)
	{
		return a.x < b.x;
	});

	line l = { 0, 0 };
	add_line(l);
	int ans = -INF;
	lop(k, 1, n + 1)
	{
		dp[k] = find_best(-arr[k].y) + (arr[k].x * arr[k].y) - arr[k].a;
		l = {arr[k].x, (int)dp[k]};
		add_line(l);
		ans = max(ans, dp[k]);
	}

	cout << ans ;
}

int32_t main()
{

	ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);
	int t = 1;
	//cin >> t;
	while (t--) solve();

}

inline void INP()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt",  "r",  stdin);
	freopen("output.txt", "w", stdout);
#endif
}

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //


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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

#define ll long long
struct Line {
	mutable ll m, c, p;
	bool operator<(const Line &B) const { return m < B.m; } // const after function name, makes this const
	bool operator<(const ll &X) const { return p < X;}	// const after function name,
};

struct LineContainer: multiset< Line, less<> >  {
	ll div(int a, int b) { return a / b - ( (a ^ b) < 0 and (a % b)); }

	bool isect(iterator x, iterator y) {
		if (y == end()) { x->p = INF; return false;}
		else if (x->m == y->m) x->p = (x->c >= y->c) ? INF : -INF;
		else x->p = div(x->c - y->c, y->m - x->m);
		return x->p >= y->p;
	}
	void add(ll m, ll c) {
		auto z = insert({m, c, 0}), y = z++, x = y;
		while (isect(y, z))  z = erase(z);
		if (x != begin() and isect(--x, y)) isect(x, y = erase(y));
		while ( (y = x) != begin() and (--x)->p >= y->p ) isect(x, erase(y));
	}
	ll best(ll x) {
		assert(!empty());
		auto L = *lower_bound(x);
		return L.m * x + L.c;
	}
};

struct rec {
	int x, y, a;
};
void solve()
{
	int n; cin >> n;
	vector<rec> vec(n);
	lop(i, 0, n) cin >> vec[i].x >> vec[i].y  >> vec[i].a;

	sort(all(vec), [&](rec a, rec b) { return a.x < b.x;});

	/*
	  	dp[i] =      max: 0<='j' < i( dp[j] + ( vec[i].x - vec[j].x)*vec[i].y  - vec[i].a )
	  	dp[i] = 	 max: 0<='j' < i( dp[j] - vec[j].x*vec[i].y + vec[i].x*vec[i].y - vec[i].a );
	  	dp[i] = 	 [max: 0<='j' < i( dp[j] + vec[j].x( -vec[i].y) ] + vec[i].x * vec[i].y - vec[i].a);
	  	Line equation = (vec[j].x) * (-vec[i].y) + dp[j]
	  	Line equation = m*X + c			->  m : vec[j].x, c : dp[j], X = -vec[i].y
	*/
	// return;
	LineContainer hull_trick;
	hull_trick.add(0, 0);
	// return;
	int ans = 0;
	lop(i, 0, n)
	{
		int dp = hull_trick.best(-vec[i].y) + ( (vec[i].x * vec[i].y) - vec[i].a);
		ans = max(ans, dp);
		hull_trick.add(vec[i].x, dp);
	}
	cout << ans << endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);

	int test = 1;
	// cin >> test;
	while (test--)solve();

}


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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

#define bug(...)                                  __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{     rtn
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

inline void INP();
const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q;

// :: convex_hull_trick ::
#define ll long long
#define ld long double
struct line
{
      ll m, c;
};

ld intersectX(line a, line b)
{
      if( a.m == b.m ) return INF;
      ld x = (ld)(b.c - a.c)/(ld)(a.m - b.m);
      return x;
}

ld eval(line l, ll x){ return ((1.0)*(l.m)*x + (1.0)*l.c); }

deque< line > st;
vector< ld > points;

void add_line(line X)
{
      if( st.empty() ) st.push_back(X);
      else if( st.size() == 1 )
      {
            points.push_back( intersectX(X, st.back()) );
            st.push_back(X);
      }
      else
      {
            while( st.size() > 1 )
            {
                  line l1 = st.back(); st.pop_back();
                  if( intersectX(X, st.back()) > points.back() )
                  {
                        st.push_back(l1);
                        break;
                  }
                  else points.pop_back();
            }
            points.push_back( intersectX(X, st.back()) );
            st.push_back(X);
      }
}

ld find_best(int x)
{
      int idx = lower_bound(points.begin(), points.end(), x) - points.begin();
      return eval( st[idx], x );
}

int brr[N];
struct rec
{
      int x, y, a;
};

rec arr[N];
ld dp[N];

void solve()
{
      cin >> n;
      lop(i,1,n+1) cin >> arr[i].x >> arr[i].y >> arr[i].a;

      sort(arr+1, arr+n+1, [&](rec &a, rec &b)
      {
            return a.x < b.x;
      });

      dp[1] = arr[1].x*arr[1].y - arr[1].a;
      line l = { arr[1].x, (int)dp[1]};
      add_line(l);
      int ans = dp[1];
      lop(k,2,n+1)
      {
            dp[k] = find_best(-arr[k].y) + (arr[k].x*arr[k].y) - arr[k].a;
            l = {arr[k].x, (int)dp[k]};
            add_line(l);
      }

      lop(i,1,n+1) ans= max(ans, (int)dp[i]);
      cout << ans ;
}

int32_t main()
{

      ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);
      INP();
      int t = 1;
      //cin >> t;
      while(t--) solve();

}

inline void INP()
{
      #ifndef ONLINE_JUDGE
          freopen("input.txt",  "r",  stdin);
          freopen("output.txt", "w", stdout);
      #endif
}

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //


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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

#define bug(...)                                  __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{     rtn
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

inline void INP();
const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q;

// :: convex_hull_trick ::
#define ll long long
#define ld long double
struct line
{
      ll m, c;
};

ld intersectX(line a, line b)
{
      if( a.m == b.m ) return INT_MAX;
      ld x = (double)(b.c - a.c)/(double)(a.m - b.m);
      return x;
}

ll eval(line l, ll x){ return ((l.m)*x + l.c); }

deque< line > st;
vector< ld > points;

void add_line(line X)
{
      if( st.empty() ) st.push_back(X);
      else if( st.size() == 1 )
      {
            points.push_back( intersectX(X, st.back()) );
            st.push_back(X);
      }
      else
      {
            while( st.size() > 1 )
            {
                  line l1 = st.back(); st.pop_back();
                  if( intersectX(X, st.back()) > points.back() )
                  {
                        st.push_back(l1);
                        break;
                  }
                  else points.pop_back();
            }
            points.push_back( intersectX(X, st.back()) );
            st.push_back(X);
      }
}

ll find_best(int x)
{
      int idx = lower_bound(points.begin(), points.end(), x) - points.begin();
      return eval( st[idx], x );
}

int brr[N];
struct rec
{
      int x, y, a;
};

void solve()
{
      cin >> n;
      rec arr[n+1];
      lop(i,1,n+1) cin >> arr[i].x >> arr[i].y >> arr[i].a;
      sort(arr+1, arr+n+1, [&](rec &a, rec &b)
      {
            return a.x < b.x;
      });

      int dp[n+1];
      dp[1] = arr[1].x*arr[1].y - arr[1].a;
      line l = { arr[1].x, dp[1]};
      add_line(l);
      lop(k,2,n+1)
      {
            dp[k] = find_best(-arr[k].y) + arr[k].x*arr[k].y - arr[k].a;
            l = { arr[k].x, dp[k]};
            add_line(l);
      }

      int ans = -INF;
      lop(i,1,n+1) ans= max(ans, dp[i]);
      cout << ans ;

}

int32_t main()
{

      ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);
      INP();
      int t = 1;
      //cin >> t;
      while(t--) solve();

}

inline void INP()
{
      #ifndef ONLINE_JUDGE
          freopen("input.txt",  "r",  stdin);
          freopen("output.txt", "w", stdout);
      #endif
}

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //


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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

#define bug(...)                                  __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{	rtn
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

inline void INP();
const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q;

// :: convex_hull_trick ::
#define ll long long
struct line { ll m, c; };

ll divide(ll a, ll b) { return a / b - ( (a ^ b) < 0 and (a % b) );}
ll intersectX(line &l1, line &l2) {
	if (l1.m == l2.m) return -(ll)1e16;
	return divide(l1.c - l2.c, l2.m - l1.m);
}

vector<ll> points;
deque<line> st;

void add_line(line nline) {
	if ( st.size() == 0 ) st.pb(nline);
	else if ( st.size() == 1 ) points.pb( intersectX(nline, st.back()) ), st.pb(nline);
	else {
		while ( (int)st.size() > 1 and intersectX(nline, st.back()) <= points.back() ) {
			st.pop_back();
			points.pop_back();
		}
		if ( st.size() ) points.pb( intersectX(nline, st.back()) );
		st.pb(nline);
	}
}

ll find_best(int x) {
	int id = lower_bound( all(points), (ll)x ) - points.begin();
	return st[id].m * x + st[id].c;
}

int brr[N];
struct rec
{
	int x, y, a;
};

rec arr[N];
ll dp[N];

void solve()
{
	cin >> n;
	lop(i, 1, n + 1) cin >> arr[i].x >> arr[i].y >> arr[i].a;

	sort(arr + 1, arr + n + 1, [&](rec & a, rec & b)
	{
		return a.x < b.x;
	});

	line l = { 0, 0 };
	add_line(l);
	int ans = -INF;
	lop(k, 1, n + 1)
	{
		dp[k] = find_best(-arr[k].y) + (arr[k].x * arr[k].y) - arr[k].a;
		l = {arr[k].x, (int)dp[k]};
		add_line(l);
		ans = max(ans, dp[k]);
	}

	cout << ans ;
}

int32_t main()
{

	ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);
	int t = 1;
	//cin >> t;
	while (t--) solve();

}

inline void INP()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt",  "r",  stdin);
	freopen("output.txt", "w", stdout);
#endif
}

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //


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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

#define bug(...)                                  __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{     rtn
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

inline void INP();
const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q;

// :: convex_hull_trick ::
#define ll long long
#define ld long double
struct line
{
      ll m, c;
};

ld intersectX(line a, line b)
{
      if( a.m == b.m ) return INF;
      ld x = (ld)(b.c - a.c)/(ld)(a.m - b.m);
      return x;
}

ll eval(line l, ll x){ return ((l.m)*x + l.c); }

deque< line > st;
vector< ld > points;

void add_line(line X)
{
      if( st.empty() ) st.push_back(X);
      else if( st.size() == 1 )
      {
            points.push_back( intersectX(X, st.back()) );
            st.push_back(X);
      }
      else
      {
            while( st.size() > 1 )
            {
                  line l1 = st.back(); st.pop_back();
                  if( intersectX(X, st.back()) > points.back() )
                  {
                        st.push_back(l1);
                        break;
                  }
                  else points.pop_back();
            }
            points.push_back( intersectX(X, st.back()) );
            st.push_back(X);
      }
}

ll find_best(int x)
{
      int idx = lower_bound(points.begin(), points.end(), x) - points.begin();
      return eval( st[idx], x );
}

int brr[N];
struct rec
{
      int x, y, a;
};

rec arr[N];
ll dp[N];

void solve()
{
      cin >> n;
      lop(i,1,n+1) cin >> arr[i].x >> arr[i].y >> arr[i].a;

      sort(arr+1, arr+n+1, [&](rec &a, rec &b)
      {
            return a.x < b.x;
      });

      line l = { 0,0 };
      add_line(l);
      int ans = -INF;
      lop(k,1,n+1)
      {
            dp[k] = find_best(-arr[k].y) + (arr[k].x*arr[k].y) - arr[k].a;
            l = {arr[k].x, (int)dp[k]};
            add_line(l);
            ans = max(ans, dp[k]);
      }

      cout << ans ;
}

int32_t main()
{

      ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);
      INP();
      int t = 1;
      //cin >> t;
      while(t--) solve();

}

inline void INP()
{
      #ifndef ONLINE_JUDGE
          freopen("input.txt",  "r",  stdin);
          freopen("output.txt", "w", stdout);
      #endif
}

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //


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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

#define ll long long
struct Line {
	mutable ll m, c, p;
	bool operator<(const Line &B) const { return m < B.m; } // const after function name, makes this const
	bool operator<(const ll &X) const { return p < X;}	// const after function name,
};

struct LineContainer: multiset< Line, less<> >  {
	ll div(int a, int b) { return a / b - ( (a ^ b) < 0 and (a % b)); }

	bool isect(iterator x, iterator y) {
		if (y == end()) { x->p = INF; return false;}
		else if (x->m == y->m) x->p = (x->c >= y->c) ? INF : -INF;
		else x->p = div(x->c - y->c, y->m - x->m);
		return x->p >= y->p;
	}
	void add(ll m, ll c) {
		auto z = insert({m, c, 0}), y = z++, x = y;
		while (isect(y, z) )  z = erase(z);
		if (x != begin() and isect(--x, y)) isect(x, erase(y));
		while ( (y = x) != begin() and (--x)->p >= y->p ) isect(x, erase(y));
	}
	ll best(ll x) {
		assert(!empty());
		auto L = *lower_bound(x);
		return L.m * x + L.c;
	}
};

struct rec {
	int x, y, a;
};

void solve()
{
	int n; cin >> n;
	vector<rec> vec(n);
	lop(i, 0, n) cin >> vec[i].x >> vec[i].y  >> vec[i].a;

	sort(all(vec), [&](rec a, rec b) { return a.x < b.x;});

	/*
	  	dp[i] =      max: 0<='j' < i( dp[j] + ( vec[i].x - vec[j].x)*vec[i].y  - vec[i].a )
	  	dp[i] = 	 max: 0<='j' < i( dp[j] - vec[j].x*vec[i].y + vec[i].x*vec[i].y - vec[i].a );
	  	dp[i] = 	 [max: 0<='j' < i( dp[j] + vec[j].x( -vec[i].y) ] + vec[i].x * vec[i].y - vec[i].a);
	  	Line equation = (vec[j].x) * (-vec[i].y) + dp[j]
	  	Line equation = m*X + c			->  m : vec[j].x, c : dp[j], X = -vec[i].y
	*/
	// return;
	LineContainer hull_trick;
	hull_trick.add(0, 0);
	// return;
	int ans = 0;
	lop(i, 0, n)
	{
		int dp = hull_trick.best(-vec[i].y) + ( (vec[i].x * vec[i].y) - vec[i].a);
		ans = max(ans, dp);
		hull_trick.add(vec[i].x, dp);
	}
	cout << ans << endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);

	int test = 1;
	// cin >> test;
	while (test--)solve();

}


#include <iostream>
#include <string>
using namespace std;

int main(){
	 int n;
	cin>>n;
	string s;
	bool is=true;
	for(int i=0;i<n;i++){
		if(i==0){
			s=to_string(n);
			is=!is;
			continue;
		}
		if(is)s=to_string((i))+s;
		else s=s+to_string(i);
		is=!is;
	}
	cout<<s<<endl;
	return 0;

}


#include <iostream>
#include <string>
using namespace std;

int main(){
	long long  n;
	cin>>n;
	string s,sl;
	bool is=true;
	for(long long i=1;i<n+1;i=i+1){
		//cout<<i<<endl;
		if(i==1)s=to_string(i);
		else if(n/2>=i){
			s=s+" "+to_string(i);
		}else{
			if(is){
				sl=to_string(i);
				is=!is;}
			else sl= sl+" "+to_string(i);
		}
	}
	if(n==1) cout<<s<<endl;
	else cout<<sl<<" "<<s<<endl;
	return 0;

}


#include <iostream>
#include <string>
using namespace std;

int main(){
	long long  n;
	cin>>n;
	long long sum=100000;
	long long ite=0;
	for(long long i=1;i<=n/2;i++){
		long long aux=0;
		if(n%i>0)aux=1;
		if(i+(n/i+aux)<sum){
			ite=i;
			sum=i+(n/i+aux);
		}
	}
	if(n==1)ite=1;
	string s,sl;
	//cout<<ite<<endl;
	for(int i=1;i<=n;i=i){
		sl="";
		for(int j=0;j<ite;j++){
			if(j==0)sl=to_string(i);
			else sl=sl+" "+to_string(i);
			i++;
			if(i>n)break;
		}
		s=sl+" "+s;
	}

	cout<<s<<endl;
	return 0;

}


#include <iostream>
#include <string>
using namespace std;

int main(){
	long long  n;
	cin>>n;
	string s;
	bool is=false;
	for(long long i=1;i<n+1;i=i+2){
		//cout<<i<<endl;
		if(i+1<n+1){
			if(i==1){
				s=to_string(i)+" "+to_string(i+1);
				is=!is;
				continue;
			}
			else{
				if(is)s=to_string((i))+" "+to_string(i+1)+" "+s;
				else s=s+" "+to_string(i)+" "+to_string(i+1);
				is=!is;
			}
		}
		else{
			if(is)s=to_string(i)+" "+s;
			else s=s+" "+to_string(i);
		 	is=!is;
		}
	}
	cout<<s<<endl;
	return 0;

}


#include <iostream>
#include <string>
using namespace std;

int main(){
	 int n;
	cin>>n;
	string s;
	bool is=true;
	for(int i=0;i<n;i++){
		if(i==0){
			s=to_string(n);
			is=!is;
			continue;
		}
		if(is)s=to_string((i))+" "+s;
		else s=s+" "+to_string(i);
		is=!is;
	}
	cout<<s<<endl;
	return 0;

}


#include <iostream>
#include <string>
using namespace std;

int main(){
	long long  n;
	cin>>n;
	string s;
	bool is=true;
	for(long long i=0;i<n;i++){
		if(i==0){
			s=to_string(n);
			is=!is;
			continue;
		}
		if(is)s=to_string((i))+" "+s;
		else s=s+" "+to_string(i);
		is=!is;
	}
	cout<<s<<endl;
	return 0;

}


#include <iostream>
#include <string>
using namespace std;

int main(){
	long long  n;
	cin>>n;
	string s;
	bool is=false;
	for(long long i=1;i<n+1;i=i+2){
		//cout<<i<<endl;
		if(i+1<n+1){
			if(i==1){
				s=to_string(i)+" "+to_string(i+1);
				is=!is;
				continue;
			}
			else{
				if(is)s=to_string((i))+" "+to_string(i+1)+" "+s;
				else s=s+" "+to_string(i)+" "+to_string(i+1);
				is=!is;
			}
		}
		else{
			if(i==1)s=to_string(i);
			else if(is)s=to_string(i)+" "+s;
			else s=s+" "+to_string(i);
		 	is=!is;
		}
	}
	cout<<s<<endl;
	return 0;

}


#pragma clang diagnostic push
#pragma ide diagnostic ignored "cert-err34-c"

#include <bits/stdc++.h>

#define FIO  freopen("input.txt","r",stdin);  freopen("output.txt","w",stdout);
#define F first
#define S second
#define gcd __gcd
#define fast  ios_base::sync_with_stdio(false);  cin.tie(nullptr), cout.tie(nullptr)
#define LL long long
#define mod (LL)1000000007
#define N 100001
#define pii pair<int, int>
#define pi acos(-1)
using namespace std;

LL power(LL x, LL y) {
    LL ans = 1;
    while (y) {
        if (y % 2 == 1)ans *= x;
        x *= x;
        x %= mod;
        ans %= mod;
        y /= 2;
    }
    return ans;
}

void itb(bool *a, int n, int x) {
    int d = 1;
    while (x) {
        if (x % 2 == 0)a[n - d++] = '0';
        else a[n - d++] = '1';
        x /= 2;
    }
}

int main() {
    fast;
    int n;
    cin >> n;
    bool b = false;
    if (n == 1)cout << 1;
    else {
        for (int i = n; i > 0; i--) {
            if (i == 1)cout << 1 << " ";
            else {
                cout << i - 1 << " ";
                cout << i << " ";
            }
            i--;
            b = !b;
        }
    }
}


#pragma clang diagnostic push
#pragma ide diagnostic ignored "cert-err34-c"

#include <bits/stdc++.h>

#define FIO  freopen("input.txt","r",stdin);  freopen("output.txt","w",stdout);
#define F first
#define S second
#define gcd __gcd
#define fast  ios_base::sync_with_stdio(false);  cin.tie(nullptr), cout.tie(nullptr)
#define LL long long
#define mod (LL)1000000007
#define N 100001
#define pii pair<int, int>
#define pi acos(-1)
using namespace std;

LL power(LL x, LL y) {
    LL ans = 1;
    while (y) {
        if (y % 2 == 1)ans *= x;
        x *= x;
        x %= mod;
        ans %= mod;
        y /= 2;
    }
    return ans;
}

void itb(bool *a, int n, int x) {
    int d = 1;
    while (x) {
        if (x % 2 == 0)a[n - d++] = '0';
        else a[n - d++] = '1';
        x /= 2;
    }
}

int main() {
    fast;
    int n;
    cin >> n;
    bool b = false;
    if (n == 1)cout << 1;
    else {
        int c = n + 1, d = 1;
        for (int i = 2; i <= n; i++)
            if (ceil(n / i) + i < c) {
                c = (int) ceil(((double) n / (double) i)) + i;
                d = i;
            }
        for (int i = n; i > 0; i -= d)
            for (int j = min(1, i - d + 1); j <= i; j++)
                cout << j << " ";
    }
}


#pragma clang diagnostic push
#pragma ide diagnostic ignored "cert-err34-c"

#include <bits/stdc++.h>

#define FIO  freopen("input.txt","r",stdin);  freopen("output.txt","w",stdout);
#define F first
#define S second
#define gcd __gcd
#define fast  ios_base::sync_with_stdio(false);  cin.tie(nullptr), cout.tie(nullptr)
#define LL long long
#define mod (LL)1000000007
#define N 100001
#define pii pair<int, int>
#define pi acos(-1)
using namespace std;

LL power(LL x, LL y) {
    LL ans = 1;
    while (y) {
        if (y % 2 == 1)ans *= x;
        x *= x;
        x %= mod;
        ans %= mod;
        y /= 2;
    }
    return ans;
}

void itb(bool *a, int n, int x) {
    int d = 1;
    while (x) {
        if (x % 2 == 0)a[n - d++] = '0';
        else a[n - d++] = '1';
        x /= 2;
    }
}

int main() {
    fast;
    int n;
    cin >> n;
    bool b = false;
    if (n == 1)cout << 1;
    else {
        int c = n + 1, d = 1;
        for (int i = 2; i <= n; i++)
            if (ceil(n / i) + i < c) {
                c = (int) ceil(((double)n / (double)i)) + i;
                d = i;
            }
        for (int i = n; i > 0; i -= d)
            for (int j = i - d + 1; j <= i; j++)
                cout << j << " ";
    }
}


#pragma clang diagnostic push
#pragma ide diagnostic ignored "cert-err34-c"

#include <bits/stdc++.h>

#define FIO  freopen("input.txt","r",stdin);  freopen("output.txt","w",stdout);
#define F first
#define S second
#define gcd __gcd
#define fast  ios_base::sync_with_stdio(false);  cin.tie(nullptr), cout.tie(nullptr)
#define LL long long
#define mod (LL)1000000007
#define N 100001
#define pii pair<int, int>
#define pi acos(-1)
using namespace std;

LL power(LL x, LL y) {
    LL ans = 1;
    while (y) {
        if (y % 2 == 1)ans *= x;
        x *= x;
        x %= mod;
        ans %= mod;
        y /= 2;
    }
    return ans;
}

void itb(bool *a, int n, int x) {
    int d = 1;
    while (x) {
        if (x % 2 == 0)a[n - d++] = '0';
        else a[n - d++] = '1';
        x /= 2;
    }
}

int main() {
    fast;
    int n;
    cin >> n;
    for (int i = 2; i <= n; i++) {
        cout << i << " ";
    }
    cout << 1;
}


#pragma clang diagnostic push
#pragma ide diagnostic ignored "cert-err34-c"

#include <bits/stdc++.h>

#define FIO  freopen("input.txt","r",stdin);  freopen("output.txt","w",stdout);
#define F first
#define S second
#define gcd __gcd
#define fast  ios_base::sync_with_stdio(false);  cin.tie(nullptr), cout.tie(nullptr)
#define LL long long
#define mod (LL)1000000007
#define N 100001
#define pii pair<int, int>
#define pi acos(-1)
using namespace std;

LL power(LL x, LL y) {
    LL ans = 1;
    while (y) {
        if (y % 2 == 1)ans *= x;
        x *= x;
        x %= mod;
        ans %= mod;
        y /= 2;
    }
    return ans;
}

void itb(bool *a, int n, int x) {
    int d = 1;
    while (x) {
        if (x % 2 == 0)a[n - d++] = '0';
        else a[n - d++] = '1';
        x /= 2;
    }
}

int main() {
    fast;
    int n;
    cin >> n;
    bool b = false;
    if (n == 1)cout << 1;
    else {
        int c = n + 1, d = 1;
        for (int i = 2; i <= n; i++)
            if (ceil(n / i) + i < c) {
                c = (int) ceil(((double) n / (double) i)) + i;
                d = i;
            }
        for (int i = n; i > 0; i -= d)
            for (int j = max(1, i - d + 1); j <= i; j++)
                cout << j << " ";
    }
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1000010;
int a[maxn];
int main()
{
	int N,tN,i,j,pos=0;
	scanf("%d",&N); tN=sqrt(N);
	int p=N;
	for(i=1;i<=tN;i++){
		for(j=i*tN;j>=(i-1)*tN+1;j--) a[j]=p--;
	}
	for(i=N;i>=tN*tN+1;i--) a[i]=p--;
	for(i=1;i<=N;i++) printf("%d ",a[i]);
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1000010;
int a[maxn];
int main()
{
	int N,tN,i,j,pos=0;
	scanf("%d",&N); tN=sqrt(N);
	int p=N;
	for(i=tN*tN+1;i<=N;i++) a[++pos]=p--;
	for(i=1;i<=tN;i++){
		int p=i*tN;
		for(j=(i-1)*tN+1;j<=i*tN;j++) a[++pos]=p--;
	}

	for(i=N;i>=1;i--) printf("%d ",a[i]);
	return 0;
}


 #include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1000010;
int a[maxn];
int main()
{
	int N,tN,i,j,pos=0;
	scanf("%d",&N); tN=sqrt(N);
	int p=N;
	for(i=1;i<=N;i+=tN){
		for(j=min(i+tN-1,N);j>=i;j--) a[j]=p--;
	}
	for(i=1;i<=N;i++) printf("%d ",a[i]);
	return 0;
}


 #include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1000010;
int a[maxn];
int main()
{
	int N,tN,i,j,pos=0;
	scanf("%d",&N); tN=sqrt(N);
	int p=N;
	for(i=1;i<=tN+1;i++){
		for(j=min(i*tN,N);j>=(i-1)*tN+1;j--) a[j]=p--;
	}
	for(i=1;i<=N;i++) printf("%d ",a[i]);
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1000010;
int a[maxn];
int main()
{
	int N,tN,i,j,pos=0;
	scanf("%d",&N); tN=sqrt(N);
	int p=N;
	for(i=N;i>=tN*tN+1;i--) a[++pos]=p--;
	for(i=1;i<=tN;i++){
		int p=i*tN;
		for(j=(i-1)*tN+1;j<=i*tN;j++) a[++pos]=p--;
	}
	for(i=N;i>=1;i--) printf("%d ",a[i]);
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1000010;
int a[maxn];
int main()
{
	int N,tN,i,j;
	scanf("%d",&N); tN=sqrt(N);
	for(i=1;i<=tN;i++){
		int p=i*tN;
		for(j=(i-1)*tN+1;j<=i*tN;j++) a[j]=p--;
	}
	int p=N;
	for(i=tN*tN+1;i<=N;i++) a[i]=p--;
	for(i=N;i>=1;i--) printf("%d ",a[i]);
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1000010;
int a[maxn];
int main()
{
	int N,tN,i,j,pos=0;
	scanf("%d",&N); tN=sqrt(N);
	int p=N;
	for(i=1;i<=tN;i++){
		for(j=i*tN;j>=(i-1)*tN+1;j--) a[j]=p--;
	}
	for(i=tN*tN+1;i<=N;i++) a[i]=p--;
	for(i=1;i<=N;i++) printf("%d ",a[i]);
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1000010;
int a[maxn];
int main()
{
	int N,tN,i,j;
	scanf("%d",&N); tN=sqrt(N);
	for(i=1;i<=tN;i++){
		int p=i*tN;
		for(j=(i-1)*tN+1;j<=i*tN;j++) a[j]=p--;
	}
	int p=N;
	for(i=tN*tN+1;i<=N;i++) a[i]=p--;
	for(i=1;i<=N;i++) printf("%d ",a[i]);
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1000010;
int a[maxn];
int main()
{
	int N,tN,i,j;
	scanf("%d",&N); tN=sqrt(N)+1;
	for(i=1;i<=tN;i++){
		int p=i*tN;
		for(j=(i-1)*tN+1;j<=i*tN;j++) a[j]=p--;
	}
	int p=N;
	for(i=tN*tN+1;i<=N;i++) a[i]=p--;
	for(i=1;i<=N;i++) printf("%d ",a[i]);
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1000010;
int a[maxn];
int main()
{
	int N,tN,i,j;
	scanf("%d",&N); tN=sqrt(N);
	if(abs(tN*tN-N)>(abs((tN+1)*(tN+1)-N))) tN++;
	for(i=1;i<=tN;i++){
		int p=i*tN;
		for(j=(i-1)*tN+1;j<=i*tN;j++) a[j]=p--;
	}
	int p=N;
	for(i=tN*tN+1;i<=N;i++) a[i]=p--;
	for(i=1;i<=N;i++) printf("%d ",a[i]);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=1000010;
int a[maxn];
int main()
{
	int N,tN,i,j;
	scanf("%d",&N); tN=sqrt(N); int p=N;
	for(i=1;i<=N;i+=tN){
		for(j=min(N,i+tN-1);j>=i;j--) a[j]=p--;
	}
	for(i=1;i<=N;i++) printf("%d ",a[i]);
	return 0;
}


#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)
#define plld(longvalue) printf("%lld\n", longvalue)

#define slf(longvalue) scanf("%lf", &longvalue)
#define plf(longvalue) printf("%lf\n", longvalue)
#define sc(letter) scanf("%c", &letter)
#define pc(letter) printf("%c", letter)

#define ss(name) scanf("%s", name)
#define ps(name) printf("%s", name)

#define pnew printf("\n")

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >
#define pii pair < int, int >

#define printcase(indexing,ans) printf("Case %lld: %lld\n", indexing, ans)

#define pb(x) push_back(x)

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 1000000009

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1 << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1 << pos);
}

ll arr[100005];

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

    // freopen("in.txt", "r", stdin);

    slld(n);

    if(n % 2)
    {
        arr[1] = n;

        flag = n;
        flag -= 2;
        for(i = 2; i <= n; i +=2 )
        {
            arr[i] = flag;
            arr[i + 1] = flag + 1;

            flag -= 2;
        }
    }
    else
    {
        flag = n;
        flag--;
        for(i = 1; i <= n; i +=2 )
        {
            arr[i] = flag;
            arr[i + 1] = flag + 1;

            flag -= 2;
        }
    }

    for(i = 1; i <= n; i++) cout << arr[i] << " ";

}


#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)
#define plld(longvalue) printf("%lld\n", longvalue)

#define slf(longvalue) scanf("%lf", &longvalue)
#define plf(longvalue) printf("%lf\n", longvalue)
#define sc(letter) scanf("%c", &letter)
#define pc(letter) printf("%c", letter)

#define ss(name) scanf("%s", name)
#define ps(name) printf("%s", name)

#define pnew printf("\n")

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >
#define pii pair < int, int >

#define printcase(indexing,ans) printf("Case %lld: %lld\n", indexing, ans)

#define pb(x) push_back(x)

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 1000000009

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1 << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1 << pos);
}

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

    // freopen("in.txt", "r", stdin);

    slld(n);

    for(i = 1; i <= n; i++) cout << i << " ";

}


#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)
#define plld(longvalue) printf("%lld\n", longvalue)

#define slf(longvalue) scanf("%lf", &longvalue)
#define plf(longvalue) printf("%lf\n", longvalue)
#define sc(letter) scanf("%c", &letter)
#define pc(letter) printf("%c", letter)

#define ss(name) scanf("%s", name)
#define ps(name) printf("%s", name)

#define pnew printf("\n")

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >
#define pii pair < int, int >

#define printcase(indexing,ans) printf("Case %lld: %lld\n", indexing, ans)

#define pb(x) push_back(x)

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 1000000009

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1 << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1 << pos);
}

ll arr[300005];

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

    // freopen("in.txt", "r", stdin);

    slld(n);

    ll ssq = (int) sqrt(n);

    flag = n;

    for(i = 1; i <= n; i += ssq)
    {
        flag -= ssq;
        for(j = i; j < i + ssq && j <= n; j++)
        {
//            cout << j << endl;
            arr[j] = (j - i) + flag + 1;
        }
    }

    flag = n % ssq;

    tag = (n / ssq) * ssq;

    for(i = 1; i <= flag; i++)
    {
        arr[tag + i] = i;
    }

    for(i = 1; i <= n; i++) cout << arr[i] << " ";

}


#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)
#define plld(longvalue) printf("%lld\n", longvalue)

#define slf(longvalue) scanf("%lf", &longvalue)
#define plf(longvalue) printf("%lf\n", longvalue)
#define sc(letter) scanf("%c", &letter)
#define pc(letter) printf("%c", letter)

#define ss(name) scanf("%s", name)
#define ps(name) printf("%s", name)

#define pnew printf("\n")

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >
#define pii pair < int, int >

#define printcase(indexing,ans) printf("Case %lld: %lld\n", indexing, ans)

#define pb(x) push_back(x)

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 1000000009

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1 << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1 << pos);
}

ll arr[100005];

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

    // freopen("in.txt", "r", stdin);

    slld(n);

    if(n == 1)
    {
        cout << 1 << endl;
        return 0;
    }

    if(n == 3)
    {
        cout << "1 3 2" << endl;
        return 0;
    }

    if(n % 2)
    {

        flag = n;
        flag -= 2;
        for(i = 1; i < n; i +=2 )
        {
            arr[i] = flag;
            arr[i + 1] = flag + 1;

            flag -= 2;
        }

        for(i = n; i > 4; i--) arr[i] = arr[i - 1];
        arr[4] = n;
    }
    else
    {
        flag = n;
        flag--;
        for(i = 1; i <= n; i +=2 )
        {
            arr[i] = flag;
            arr[i + 1] = flag + 1;

            flag -= 2;
        }
    }

    for(i = 1; i <= n; i++) cout << arr[i] << " ";

}


#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)
#define plld(longvalue) printf("%lld\n", longvalue)

#define slf(longvalue) scanf("%lf", &longvalue)
#define plf(longvalue) printf("%lf\n", longvalue)
#define sc(letter) scanf("%c", &letter)
#define pc(letter) printf("%c", letter)

#define ss(name) scanf("%s", name)
#define ps(name) printf("%s", name)

#define pnew printf("\n")

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >
#define pii pair < int, int >

#define printcase(indexing,ans) printf("Case %lld: %lld\n", indexing, ans)

#define pb(x) push_back(x)

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 1000000009

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1 << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1 << pos);
}

ll arr[100005];

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

    // freopen("in.txt", "r", stdin);

    slld(n);

    ll ssq = (int) sqrt(n);

    flag = n;

    for(i = 1; i <= n; i += ssq)
    {
        flag -= ssq;
        for(j = i; j < i + ssq; j++)
        {
            arr[j] = (j - i) + flag + 1;
        }
    }
    for(i = 1; i <= n; i++) cout << arr[i] << " ";

}


#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)
#define plld(longvalue) printf("%lld\n", longvalue)

#define slf(longvalue) scanf("%lf", &longvalue)
#define plf(longvalue) printf("%lf\n", longvalue)
#define sc(letter) scanf("%c", &letter)
#define pc(letter) printf("%c", letter)

#define ss(name) scanf("%s", name)
#define ps(name) printf("%s", name)

#define pnew printf("\n")

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >
#define pii pair < int, int >

#define printcase(indexing,ans) printf("Case %lld: %lld\n", indexing, ans)

#define pb(x) push_back(x)

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 1000000009

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1 << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1 << pos);
}

ll arr[100005];

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

    // freopen("in.txt", "r", stdin);

    slld(n);

    ll ssq = (int) sqrt(n);

    flag = n;

    for(i = 1; i <= n; i += ssq)
    {
        flag -= ssq;
        for(j = i; j < i + ssq; j++)
        {
            arr[j] = (j - i) + flag + 1;
        }
    }

    flag = n % ssq;

    tag = (n / ssq) * ssq;

    for(i = 1; i <= flag; i++)
    {
        arr[tag + i] = i;
    }

    for(i = 1; i <= n; i++) cout << arr[i] << " ";

}


#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)
#define plld(longvalue) printf("%lld\n", longvalue)

#define slf(longvalue) scanf("%lf", &longvalue)
#define plf(longvalue) printf("%lf\n", longvalue)
#define sc(letter) scanf("%c", &letter)
#define pc(letter) printf("%c", letter)

#define ss(name) scanf("%s", name)
#define ps(name) printf("%s", name)

#define pnew printf("\n")

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >
#define pii pair < int, int >

#define printcase(indexing,ans) printf("Case %lld: %lld\n", indexing, ans)

#define pb(x) push_back(x)

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 1000000009

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1 << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1 << pos);
}

ll arr[100005];

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

    // freopen("in.txt", "r", stdin);

    slld(n);

    if(n % 2)
    {

        flag = n;
        flag -= 2;
        for(i = 1; i < n; i +=2 )
        {
            arr[i] = flag;
            arr[i + 1] = flag + 1;

            flag -= 2;
        }

        for(i = n; i > 4; i--) arr[i] = arr[i - 1];
        arr[4] = n;
    }
    else
    {
        flag = n;
        flag--;
        for(i = 1; i <= n; i +=2 )
        {
            arr[i] = flag;
            arr[i + 1] = flag + 1;

            flag -= 2;
        }
    }

    for(i = 1; i <= n; i++) cout << arr[i] << " ";

}


#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)
#define plld(longvalue) printf("%lld\n", longvalue)

#define slf(longvalue) scanf("%lf", &longvalue)
#define plf(longvalue) printf("%lf\n", longvalue)
#define sc(letter) scanf("%c", &letter)
#define pc(letter) printf("%c", letter)

#define ss(name) scanf("%s", name)
#define ps(name) printf("%s", name)

#define pnew printf("\n")

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >
#define pii pair < int, int >

#define printcase(indexing,ans) printf("Case %lld: %lld\n", indexing, ans)

#define pb(x) push_back(x)

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 1000000009

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1 << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1 << pos);
}

ll arr[100005];

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

    // freopen("in.txt", "r", stdin);

    slld(n);

    if(n == 1)
    {
        cout << 1 << endl;
        return 0;
    }

    if(n % 2)
    {

        flag = n;
        flag -= 2;
        for(i = 1; i < n; i +=2 )
        {
            arr[i] = flag;
            arr[i + 1] = flag + 1;

            flag -= 2;
        }

        for(i = n; i > 4; i--) arr[i] = arr[i - 1];
        arr[4] = n;
    }
    else
    {
        flag = n;
        flag--;
        for(i = 1; i <= n; i +=2 )
        {
            arr[i] = flag;
            arr[i + 1] = flag + 1;

            flag -= 2;
        }
    }

    for(i = 1; i <= n; i++) cout << arr[i] << " ";

}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;
const int maxn=100000+100;
int a[maxn];
int n;
int main(){
    scanf("%d",&n);
    int m=sqrt(n);
    for(int i=1;i<=n%m;i++)
        printf("%d ",n%m-i+1);
    for(int i=1;i<=m;i++){
        for(int j=0;j<m;j++){
            printf("%d ",n%m+i*m-j);
        }
    }
return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;
const int maxn=100000+100;
int a[maxn];
int n;
int main(){
    scanf("%d",&n);
    int m=sqrt(n);
   // printf("%d\n",m);
    for(int i=1;i<=n%m;i++)
        printf("%d ",n%m-i+1);
   // printf("\n");
    for(int i=1;i<=n/m;i++){
        for(int j=0;j<m;j++){
            printf("%d ",n%m+i*m-j);
        }
    }
return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>

using namespace std;
typedef long long LL;
typedef unsigned long long ull;
const int INF=2147000000;
const LL inf=1e19;
int n;
int main(){
    scanf("%d",&n);
    printf("1 ");
    if(n==1)
        return 0;
    printf("%d ",n);

    for(int i=n-1;i>=2;i--){
        printf("%d ",i);
    }
return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>

using namespace std;
typedef long long LL;
typedef unsigned long long ull;
const int INF=2147000000;
const LL inf=1e19;
int n;
int main(){
    scanf("%d",&n);
    if(n==1){
        printf("1");
        return 0;
    }

        for(int i=n;i>=n/2+1;i--)
            printf("%d ",i);
        for(int i=1;i<=n/2;i++)
            printf("%d ",i);

return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;
const int maxn=100000+100;
int a[maxn];
int n;
int main(){
    scanf("%d",&n);
    for(int i=3;i<=n;i+=3){
        for(int j=0;j<3;j++){
            printf("%d ",i-j);
        }
    }
    for(int i=1;i<=n%3;i++){
        printf("%d ",n-i+1);
    }

return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    ios::sync_with_stdio(0),cin.tie(0);
    while(cin>>n){
    if(n%2)
    {
        for(int i=1;i<=n;i++)
            if(i%2)
             cout<<i<<' ';
        for(int i=1;i<n-1;i++)
            if(i%2==0)
             cout<<i<<' ';
        cout<<n-1<<endl;
    }
    else
    {
        int mid=n/2+1;
        for(int i=mid;i<=n;i++)
            cout<<i<<' ';
        for(int i=1;i<mid-1;i++)
            cout<<i<<' ';
        cout<<mid-1<<endl;
    }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    ios::sync_with_stdio(0),cin.tie(0);
    cin>>n;
    if(n%2)
    {
        int mid=(n+1)/2;
        for(int i=mid;i<=n;i++)
            cout<<i<<' ';
        for(int i=1;i<mid-1;i++)
            cout<<i<<' ';
        cout<<mid-1<<endl;
    }
    else
    {
        int mid=n/2+1;
        for(int i=mid;i<=n;i++)
            cout<<i<<' ';
        for(int i=1;i<mid-1;i++)
            cout<<i<<' ';
        cout<<mid-1<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    ios::sync_with_stdio(0),cin.tie(0);
    while(cin>>n){
    if(n%2)
    {
        for(int i=1;i<=n;i++)
            if(i%2)
             cout<<i<<' ';
        for(int i=1;i<n-1;i++)
            if(i%2==0)
             cout<<i<<' ';
        if(n>1) cout<<n-1;
        cout<<endl;
    }
    else
    {
        int mid=n/2+1;
        for(int i=mid;i<=n;i++)
            cout<<i<<' ';
        for(int i=1;i<mid-1;i++)
            cout<<i<<' ';
        cout<<mid-1<<endl;
    }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    ios::sync_with_stdio(0),cin.tie(0);
    while(cin>>n){
    if(n%2)
    {
        int l[100001],r[100001];
        int block=(int)sqrt(n);
        int num=n/block;
        if(n%block) num++;
        for(int i=1;i<=num;i++)
            l[i]=(i-1)*block+1,r[i]=i*block;
            r[num]=n;
        for(int i=num;i>=1;i--)
            for(int j=l[i];j<=r[i];j++){
              if(i==1&&j==r[i]) cout<<j<<endl;
              else cout<<j<<' ';
            }
    }
    else
    {
        int mid=n/2+1;
        for(int i=mid;i<=n;i++)
            cout<<i<<' ';
        for(int i=1;i<mid-1;i++)
            cout<<i<<' ';
        cout<<mid-1<<endl;
    }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    ios::sync_with_stdio(0),cin.tie(0);
    while(cin>>n){
        int l[100001],r[100001];
        int block=(int)sqrt(n);
        int num=n/block;
        if(n%block) num++;
        for(int i=1;i<=num;i++)
            l[i]=(i-1)*block+1,r[i]=i*block;
            r[num]=n;
        for(int i=num;i>=1;i--)
            for(int j=l[i];j<=r[i];j++){
              if(i==1&&j==r[i]) cout<<j<<endl;
              else cout<<j<<' ';
            }
    return 0;
    }
}


#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define MOD 1000000007
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define bolt ios::sync_with_stdio(0)
#define forr(i,p,n) for(ll i=p;i<n;i++)
typedef long long ll;
using namespace std;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n%p; n = n * n%p;} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}

int main(){
	srand(time(NULL));
	bolt;
	ll n;
	cin>>n;
	ll ind=1;
	ll minn=LLONG_MAX;
	for(ll i=1;i<=n;i++){
		ll p=ceil((double)n/i);
		ll ans=p+i;
		if(ans<minn){
			minn=ans;
			ind=i;
		}
	}
	for(ll i=1;i<=n;i++){
		ll p=i;
		ll end=p+ind-1;
		for(ll j=end;j>=p;j--){
			cout<<j<<" ";
		}
		i=end;
	}
	// cout<<minn<<"\n";
}


#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define MOD 1000000007
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define bolt ios::sync_with_stdio(0)
#define forr(i,p,n) for(ll i=p;i<n;i++)
typedef long long ll;
using namespace std;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n%p; n = n * n%p;} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}

int main(){
	srand(time(NULL));
	bolt;
	ll n;
	cin>>n;
	ll ind=1;
	ll minn=LLONG_MAX;
	for(ll i=1;i<=n;i++){
		ll p=ceil((double)n/i);
		ll ans=p+i;
		if(ans<minn){
			minn=ans;
			ind=i;
		}
	}
	for(ll i=1;i<=n;i++){
		ll p=i;
		ll end=p+ind-1;
		for(ll j=min(n,end);j>=p;j--){
			cout<<j<<" ";
		}
		i=end;
	}
	// cout<<minn<<"\n";
}


#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define MOD 1000000007
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define bolt ios::sync_with_stdio(0)
#define forr(i,p,n) for(ll i=p;i<n;i++)
typedef long long ll;
using namespace std;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n%p; n = n * n%p;} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}

int main(){
	bolt;
	ll n;
	cin>>n;
	for(ll i=n/2+1;i<=n;i++){
		cout<<i<<" ";
	}
	for(ll i=1;i<=n/2;i++){
		cout<<i<<" ";
	}
	cout<<"\n";
}


#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define MOD 1000000007
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define bolt ios::sync_with_stdio(0)
#define forr(i,p,n) for(ll i=p;i<n;i++)
typedef long long ll;
using namespace std;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n%p; n = n * n%p;} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}

int main(){
	bolt;
	ll n;
	cin>>n;
	for(ll i=1;i<=n;i++){
		cout<<i<<" ";
	}
	cout<<"\n";
}