#include <bits/stdc++.h>
using namespace std;
int tmp[1000010];
struct Tree {
  long long mx;
  int pos;
} T[4000010];
long long lazy[4000010];
Tree operator+(const Tree& a, const Tree& b) {
  if (a.mx > b.mx) return a;
  return b;
}
void update(int root) {
  T[root] = T[root << 1] + T[root << 1 | 1];
  return;
}
void pushdown(int root) {
  T[root << 1].mx += lazy[root];
  T[root << 1 | 1].mx += lazy[root];
  lazy[root << 1] += lazy[root];
  lazy[root << 1 | 1] += lazy[root];
  lazy[root] = 0;
  return;
}
void build(int root, int l, int r) {
  if (l == r) {
    T[root].pos = l;
    return;
  }
  int mid = (l + r) >> 1;
  build(root << 1, l, mid);
  build(root << 1 | 1, mid + 1, r);
  update(root);
  return;
}
void add(int root, int l, int r, int x, int y, int z) {
  if (x <= l && r <= y) {
    T[root].mx += z;
    lazy[root] += z;
    return;
  }
  pushdown(root);
  int mid = (l + r) >> 1;
  if (x <= mid) add(root << 1, l, mid, x, y, z);
  if (y > mid) add(root << 1 | 1, mid + 1, r, x, y, z);
  update(root);
  return;
}
Tree query(int root, int l, int r, int x, int y) {
  if (x <= l && r <= y) return T[root];
  pushdown(root);
  int mid = (l + r) >> 1;
  if (x <= mid) {
    if (y > mid)
      return query(root << 1, l, mid, x, y) +
             query(root << 1 | 1, mid + 1, r, x, y);
    return query(root << 1, l, mid, x, y);
  }
  return query(root << 1 | 1, mid + 1, r, x, y);
}
struct Point {
  int x, y, c;
} p[500010];
bool cmp(Point a, Point b) { return a.y < b.y; }
long long ans = 0;
int ansx = 2e9, ansy = 2e9;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d %d", &p[i].x, &p[i].y, &p[i].c);
    tmp[i * 2 - 1] = p[i].x;
    tmp[i * 2] = p[i].y;
  }
  sort(tmp + 1, tmp + 2 * n + 1);
  int M = unique(tmp + 1, tmp + 2 * n + 1) - tmp - 1;
  for (int i = 1; i <= n; i++) {
    p[i].x = lower_bound(tmp + 1, tmp + M + 1, p[i].x) - tmp;
    p[i].y = lower_bound(tmp + 1, tmp + M + 1, p[i].y) - tmp;
    if (p[i].x > p[i].y) swap(p[i].x, p[i].y);
  }
  sort(p + 1, p + n + 1, cmp);
  int cur = 1;
  build(1, 1, M);
  for (int i = 1; i <= n; i++) {
    add(1, 1, M, 1, p[i].x, p[i].c);
    while (cur < p[i].y) {
      add(1, 1, M, 1, cur, tmp[cur] - tmp[cur + 1]);
      cur++;
    }
    if (i == n || p[i].y != p[i + 1].y) {
      Tree ret = query(1, 1, M, 1, p[i].y);
      if (ans < ret.mx) ans = ret.mx, ansx = ret.pos, ansy = p[i].y;
    }
  }
  printf("%I64d\n", ans);
  if (ansx <= M && ansy <= M) ansx = tmp[ansx], ansy = tmp[ansy];
  printf("%d %d %d %d\n", ansx, ansx, ansy, ansy);
  return 0;
}
