#include <bits/stdc++.h>
using namespace std;
const int N = 1000001;
const long long Q = 9223372036854775807ll;
struct line {
  long long m, p;
  mutable set<line>::iterator prev;
};
set<line>::iterator null;
bool operator<(const line& a, const line& b) {
  if (b.p != Q && a.p != Q) {
    return a.m < b.m;
  }
  if (b.p == Q) {
    if (a.prev == null) return true;
    bool ok = true;
    if ((a.prev->m - a.m) < 0) ok = !ok;
    if (ok) {
      return (a.p - a.prev->p) < (a.prev->m - a.m) * b.m;
    } else {
      return (a.p - a.prev->p) > (a.prev->m - a.m) * b.m;
    }
  } else {
    if (b.prev == null) return false;
    bool ok = true;
    if ((b.prev->m - b.m) < 0) ok = !ok;
    if (ok) {
      return !((b.p - b.prev->p) < a.m * (b.prev->m - b.m));
    } else {
      return !((b.p - b.prev->p) > a.m * (b.prev->m - b.m));
    }
  }
}
class convex_hull {
 public:
  set<line> convex;
  set<line>::iterator next(set<line>::iterator ii) {
    set<line>::iterator gg = ii;
    gg++;
    return gg;
  }
  set<line>::iterator prev(set<line>::iterator ii) {
    set<line>::iterator gg = ii;
    gg--;
    return gg;
  }
  bool bad(set<line>::iterator jj) {
    set<line>::iterator ii, kk;
    if (jj == convex.begin()) return false;
    kk = next(jj);
    if (kk == convex.end()) return false;
    ii = prev(jj);
    line a = *ii, c = *kk, b = *jj;
    bool ok = true;
    if ((b.m - a.m) < 0) ok = !ok;
    if ((b.m - c.m) < 0) ok = !ok;
    if (ok) {
      return (c.p - b.p) * (long double)(b.m - a.m) <=
             (a.p - b.p) * (long double)(b.m - c.m);
    } else {
      return (c.p - b.p) * (long double)(b.m - a.m) >=
             (a.p - b.p) * (long double)(b.m - c.m);
    }
  }
  void del(set<line>::iterator ii) {
    set<line>::iterator jj = next(ii);
    if (jj != convex.end()) {
      jj->prev = ii->prev;
    }
    convex.erase(ii);
  }
  void add(long long m, long long p) {
    null = convex.end();
    line g;
    g.m = m;
    g.p = p;
    set<line>::iterator ii = convex.find(g);
    if (ii != convex.end()) {
      if (ii->p >= p) return;
      del(ii);
    }
    convex.insert(g);
    ii = convex.find(g);
    set<line>::iterator jj = next(ii);
    if (jj != convex.end()) jj->prev = ii;
    if (ii != convex.begin()) {
      ii->prev = prev(ii);
    } else {
      ii->prev = convex.end();
    }
    if (bad(ii)) {
      del(ii);
      return;
    }
    jj = next(ii);
    while (jj != convex.end() && bad(jj)) {
      del(jj);
      jj = next(ii);
    }
    if (ii != convex.begin()) {
      jj = prev(ii);
      while (ii != convex.begin() && bad(jj)) {
        del(jj);
        jj = prev(ii);
      }
    }
  }
  long long query(long long x) {
    null = convex.end();
    line y;
    y.m = x;
    y.p = Q;
    set<line>::iterator ii = convex.lower_bound(y);
    ii--;
    return ii->m * x + ii->p;
  }
};
struct Rect {
  long long w, h, val;
  bool operator<(const Rect& r) const {
    if (w != r.w) return w > r.w;
    return h < r.h;
  }
} v[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    scanf("%lld%lld%lld", &v[i].w, &v[i].h, &v[i].val);
  sort(v, v + n);
  convex_hull H;
  H.add(0, 0);
  long long res = 0;
  for (int i = 0; i < n; ++i) {
    long long cur = -v[i].val + v[i].w * v[i].h + H.query(v[i].w);
    H.add(-v[i].h, cur);
    res = max(res, cur);
  }
  printf("%lld\n", res);
  return 0;
}

### Prompt

Please create a solution in Cpp to the following problem:

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;
const int N = 1000001;
const long long Q = 9223372036854775807ll;
struct line {
  long long m, p;
  mutable set<line>::iterator prev;
};
set<line>::iterator null;
bool operator<(const line& a, const line& b) {
  if (b.p != Q && a.p != Q) {
    return a.m < b.m;
  }
  if (b.p == Q) {
    if (a.prev == null) return true;
    bool ok = true;
    if ((a.prev->m - a.m) < 0) ok = !ok;
    if (ok) {
      return (a.p - a.prev->p) < (a.prev->m - a.m) * b.m;
    } else {
      return (a.p - a.prev->p) > (a.prev->m - a.m) * b.m;
    }
  } else {
    if (b.prev == null) return false;
    bool ok = true;
    if ((b.prev->m - b.m) < 0) ok = !ok;
    if (ok) {
      return !((b.p - b.prev->p) < a.m * (b.prev->m - b.m));
    } else {
      return !((b.p - b.prev->p) > a.m * (b.prev->m - b.m));
    }
  }
}
class convex_hull {
 public:
  set<line> convex;
  set<line>::iterator next(set<line>::iterator ii) {
    set<line>::iterator gg = ii;
    gg++;
    return gg;
  }
  set<line>::iterator prev(set<line>::iterator ii) {
    set<line>::iterator gg = ii;
    gg--;
    return gg;
  }
  bool bad(set<line>::iterator jj) {
    set<line>::iterator ii, kk;
    if (jj == convex.begin()) return false;
    kk = next(jj);
    if (kk == convex.end()) return false;
    ii = prev(jj);
    line a = *ii, c = *kk, b = *jj;
    bool ok = true;
    if ((b.m - a.m) < 0) ok = !ok;
    if ((b.m - c.m) < 0) ok = !ok;
    if (ok) {
      return (c.p - b.p) * (long double)(b.m - a.m) <=
             (a.p - b.p) * (long double)(b.m - c.m);
    } else {
      return (c.p - b.p) * (long double)(b.m - a.m) >=
             (a.p - b.p) * (long double)(b.m - c.m);
    }
  }
  void del(set<line>::iterator ii) {
    set<line>::iterator jj = next(ii);
    if (jj != convex.end()) {
      jj->prev = ii->prev;
    }
    convex.erase(ii);
  }
  void add(long long m, long long p) {
    null = convex.end();
    line g;
    g.m = m;
    g.p = p;
    set<line>::iterator ii = convex.find(g);
    if (ii != convex.end()) {
      if (ii->p >= p) return;
      del(ii);
    }
    convex.insert(g);
    ii = convex.find(g);
    set<line>::iterator jj = next(ii);
    if (jj != convex.end()) jj->prev = ii;
    if (ii != convex.begin()) {
      ii->prev = prev(ii);
    } else {
      ii->prev = convex.end();
    }
    if (bad(ii)) {
      del(ii);
      return;
    }
    jj = next(ii);
    while (jj != convex.end() && bad(jj)) {
      del(jj);
      jj = next(ii);
    }
    if (ii != convex.begin()) {
      jj = prev(ii);
      while (ii != convex.begin() && bad(jj)) {
        del(jj);
        jj = prev(ii);
      }
    }
  }
  long long query(long long x) {
    null = convex.end();
    line y;
    y.m = x;
    y.p = Q;
    set<line>::iterator ii = convex.lower_bound(y);
    ii--;
    return ii->m * x + ii->p;
  }
};
struct Rect {
  long long w, h, val;
  bool operator<(const Rect& r) const {
    if (w != r.w) return w > r.w;
    return h < r.h;
  }
} v[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    scanf("%lld%lld%lld", &v[i].w, &v[i].h, &v[i].val);
  sort(v, v + n);
  convex_hull H;
  H.add(0, 0);
  long long res = 0;
  for (int i = 0; i < n; ++i) {
    long long cur = -v[i].val + v[i].w * v[i].h + H.query(v[i].w);
    H.add(-v[i].h, cur);
    res = max(res, cur);
  }
  printf("%lld\n", res);
  return 0;
}

```