#include <bits/stdc++.h>
using namespace std;
struct Line {
  long long M, P;
  Line(long long m = 0, long long p = 0) {
    M = m;
    P = p;
  }
};
struct Node {
  long long l, r;
  Node *lft, *rgt;
  Line L;
  Node(long long l1, long long r1) : L(0, 0) {
    l = l1;
    r = r1;
    lft = 0;
    rgt = 0;
  }
};
long long n;
pair<pair<long long, long long>, long long> a[1000010];
long long dp[1000010];
long long ans = 0;
Node* seg;
long long fun(Line L, long long x) { return L.M * x + L.P; }
void update(Line val, Node* nod = seg) {
  long long l = nod->l, r = nod->r;
  Line old = nod->L;
  long long mid = (l + r) / 2;
  long long lf = fun(val, l) - fun(old, l);
  long long rg = fun(val, r) - fun(old, r);
  long long md = fun(val, mid) - fun(old, mid);
  long long d;
  if (lf >= 0 && rg >= 0) {
    nod->L = val;
    return;
  }
  if (lf <= 0 && rg <= 0) {
    return;
  }
  if (md >= 0) {
    nod->L = val;
    if (lf > 0)
      d = 2;
    else
      d = 1;
  } else {
    swap(val, old);
    if (lf > 0)
      d = 1;
    else
      d = 2;
  }
  if (d == 1) {
    if (nod->lft == 0) nod->lft = new Node(l, mid);
    update(old, nod->lft);
  } else {
    if (nod->rgt == 0) nod->rgt = new Node(mid + 1, r);
    update(old, nod->rgt);
  }
}
void add(long long m, long long p) {
  Line x(m, p);
  update(x);
}
long long query(long long x, Node* nod = seg) {
  long long l = nod->l, r = nod->r;
  Line old = nod->L;
  long long mid = (l + r) / 2;
  long long res = fun(old, x);
  if (x <= mid) {
    if (nod->lft == 0) {
      return max(res, 0ll);
    }
    return max(res, query(x, nod->lft));
  } else {
    if (nod->rgt == 0) {
      return max(res, 0ll);
    }
    return max(res, query(x, nod->rgt));
  }
}
int main() {
  scanf("%lld", &n);
  for (int i = 0; i < n; i++) {
    long long f, g, h;
    scanf("%lld %lld %lld", &f, &g, &h);
    a[i].first.first = f;
    a[i].first.second = g;
    a[i].second = h;
  }
  sort(a, a + n);
  seg = new Node(0, 1e9 + 10);
  add(0, 0);
  for (int idx = 0; idx < n; idx++) {
    dp[idx] = a[idx].first.first * a[idx].first.second - a[idx].second;
    long long z = query(a[idx].first.second);
    dp[idx] += z;
    ans = max(ans, dp[idx]);
    add(-a[idx].first.first, dp[idx]);
  }
  printf("%lld\n", ans);
  return 0;
}

### Prompt

Construct a cpp code solution to the problem outlined:

The Fair Nut got stacked in planar world. He should solve this task to get out.

You are given n rectangles with vertexes in (0, 0), (x_i, 0), (x_i, y_i), (0, y_i). For each rectangle, you are also given a number a_i. Choose some of them that the area of union minus sum of a_i of the chosen ones is maximum.

It is guaranteed that there are no nested rectangles.

Nut has no idea how to find the answer, so he asked for your help.

Input

The first line contains one integer n (1 ≤ n ≤ 10^6) — the number of rectangles.

Each of the next n lines contains three integers x_i, y_i and a_i (1 ≤ x_i, y_i ≤ 10^9, 0 ≤ a_i ≤ x_i ⋅ y_i).

It is guaranteed that there are no nested rectangles.

Output

In a single line print the answer to the problem — the maximum value which you can achieve.

Examples

Input


3
4 4 8
1 5 0
5 2 10


Output


9

Input


4
6 2 4
1 6 2
2 4 3
5 3 8


Output


10

Note

In the first example, the right answer can be achieved by choosing the first and the second rectangles.

In the second example, the right answer can also be achieved by choosing the first and the second rectangles.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct Line {
  long long M, P;
  Line(long long m = 0, long long p = 0) {
    M = m;
    P = p;
  }
};
struct Node {
  long long l, r;
  Node *lft, *rgt;
  Line L;
  Node(long long l1, long long r1) : L(0, 0) {
    l = l1;
    r = r1;
    lft = 0;
    rgt = 0;
  }
};
long long n;
pair<pair<long long, long long>, long long> a[1000010];
long long dp[1000010];
long long ans = 0;
Node* seg;
long long fun(Line L, long long x) { return L.M * x + L.P; }
void update(Line val, Node* nod = seg) {
  long long l = nod->l, r = nod->r;
  Line old = nod->L;
  long long mid = (l + r) / 2;
  long long lf = fun(val, l) - fun(old, l);
  long long rg = fun(val, r) - fun(old, r);
  long long md = fun(val, mid) - fun(old, mid);
  long long d;
  if (lf >= 0 && rg >= 0) {
    nod->L = val;
    return;
  }
  if (lf <= 0 && rg <= 0) {
    return;
  }
  if (md >= 0) {
    nod->L = val;
    if (lf > 0)
      d = 2;
    else
      d = 1;
  } else {
    swap(val, old);
    if (lf > 0)
      d = 1;
    else
      d = 2;
  }
  if (d == 1) {
    if (nod->lft == 0) nod->lft = new Node(l, mid);
    update(old, nod->lft);
  } else {
    if (nod->rgt == 0) nod->rgt = new Node(mid + 1, r);
    update(old, nod->rgt);
  }
}
void add(long long m, long long p) {
  Line x(m, p);
  update(x);
}
long long query(long long x, Node* nod = seg) {
  long long l = nod->l, r = nod->r;
  Line old = nod->L;
  long long mid = (l + r) / 2;
  long long res = fun(old, x);
  if (x <= mid) {
    if (nod->lft == 0) {
      return max(res, 0ll);
    }
    return max(res, query(x, nod->lft));
  } else {
    if (nod->rgt == 0) {
      return max(res, 0ll);
    }
    return max(res, query(x, nod->rgt));
  }
}
int main() {
  scanf("%lld", &n);
  for (int i = 0; i < n; i++) {
    long long f, g, h;
    scanf("%lld %lld %lld", &f, &g, &h);
    a[i].first.first = f;
    a[i].first.second = g;
    a[i].second = h;
  }
  sort(a, a + n);
  seg = new Node(0, 1e9 + 10);
  add(0, 0);
  for (int idx = 0; idx < n; idx++) {
    dp[idx] = a[idx].first.first * a[idx].first.second - a[idx].second;
    long long z = query(a[idx].first.second);
    dp[idx] += z;
    ans = max(ans, dp[idx]);
    add(-a[idx].first.first, dp[idx]);
  }
  printf("%lld\n", ans);
  return 0;
}

```