#include <bits/stdc++.h>
using namespace std;
long long x[500005], y[500005], c[500005];
long long xi[500005];
map<long long, long long> p;
long long py[1000005], per;
long long up[4 * 1000009];
long long t_max[4 * 1000009];
long long t_i[4 * 1000009];
void build(long long rt, long long l, long long r) {
  if (l == r) {
    t_max[rt] = -py[l];
    t_i[rt] = l;
    return;
  }
  long long mid = (l + r) >> 1;
  build(rt << 1, l, mid);
  build(rt << 1 | 1, mid + 1, r);
  if (t_max[rt << 1] > t_max[rt << 1 | 1]) {
    t_max[rt] = t_max[rt << 1];
    t_i[rt] = t_i[rt << 1];
  } else {
    t_max[rt] = t_max[rt << 1 | 1];
    t_i[rt] = t_i[rt << 1 | 1];
  }
}
void push_down(long long rt, long long l, long long r) {
  if (up[rt]) {
    long long mid = (l + r) >> 1;
    t_max[rt << 1] += up[rt];
    t_max[rt << 1 | 1] += up[rt];
    up[rt << 1] += up[rt];
    up[rt << 1 | 1] += up[rt];
    up[rt] = 0;
  }
}
void update(long long rt, long long l, long long r, long long x, long long y,
            long long val) {
  if (x <= l && r <= y) {
    t_max[rt] += val;
    up[rt] += val;
    return;
  }
  if (up[rt]) push_down(rt, l, r);
  long long mid = (l + r) >> 1;
  if (x <= mid) update(rt << 1, l, mid, x, y, val);
  if (y > mid) update(rt << 1 | 1, mid + 1, r, x, y, val);
  if (t_max[rt << 1] > t_max[rt << 1 | 1]) {
    t_max[rt] = t_max[rt << 1];
    t_i[rt] = t_i[rt << 1];
  } else {
    t_max[rt] = t_max[rt << 1 | 1];
    t_i[rt] = t_i[rt << 1 | 1];
  }
}
long long ans_max, ans_i;
void query(long long rt, long long l, long long r, long long x, long long y) {
  if (x <= l && r <= y) {
    if (t_max[rt] > ans_max) {
      ans_max = t_max[rt];
      ans_i = t_i[rt];
    }
    return;
  }
  if (up[rt]) push_down(rt, l, r);
  long long mid = (l + r) >> 1;
  long long maxx = 0;
  if (x <= mid) query(rt << 1, l, mid, x, y);
  if (y > mid) query(rt << 1 | 1, mid + 1, r, x, y);
}
bool cmp(long long a, long long b) { return x[a] < x[b]; }
signed main() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    xi[i] = i;
    cin >> x[i] >> y[i] >> c[i];
    if (x[i] > y[i]) swap(x[i], y[i]);
    p[x[i]] = 0, p[y[i]] = 0;
  }
  p[0] = 0;
  for (auto& a : p) {
    py[++per] = a.first;
    a.second = per;
  }
  for (long long i = 1; i <= n; i++) {
    x[i] = p[x[i]];
    y[i] = p[y[i]];
  }
  build(1, 1, per);
  sort(xi + 1, xi + 1 + n, cmp);
  long long ans = 0, ans_l = 1000000001, ans_r = 1000000001;
  for (long long i = 1; i <= n; i++) {
    update(1, 1, per, y[i], per, c[i]);
  }
  for (long long i = 1, j = 1; i <= per; i++) {
    ans_max = -123123123123123123ll, ans_i = 0;
    query(1, 1, per, i, per);
    if (ans_max > ans) {
      ans_l = py[i], ans_r = py[ans_i];
      ans = ans_max;
    }
    for (; x[xi[j]] <= i && j <= n; j++) {
      update(1, 1, per, y[xi[j]], per, -c[xi[j]]);
    }
    if (i != per) update(1, 1, per, i, per, py[i + 1] - py[i]);
  }
  cout << ans << "\n";
  cout << ans_l << " " << ans_l << " " << ans_r << " " << ans_r << "\n";
  return 0;
}
