#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0;
  char ch = getchar();
  bool f = 0;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = 1;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return f ? -x : x;
}
void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
void writeln(long long x) {
  write(x);
  puts("");
}
void writep(long long x) {
  write(x);
  putchar(' ');
}
const long long N = 500005, inf = 1 << 30;
long long n, a[N], b[N], cnt, pos[N << 2], mx[N << 2], lazy[N << 2], ansx, ansy,
    MX;
struct info {
  long long x, y, w;
} p[N];
bool used[N];
bool cmp(info a, info b) { return a.x == b.x ? a.y > b.y : a.x < b.x; }
void upd(long long k) {
  mx[k] = max(mx[k << 1], mx[k << 1 | 1]);
  if (mx[k << 1] > mx[k << 1 | 1])
    pos[k] = pos[k << 1];
  else
    pos[k] = pos[k << 1 | 1];
}
void buildtree(long long k, long long l, long long r) {
  if (l == r) {
    mx[k] = pos[k] = b[l];
    return;
  }
  long long mid = l + r >> 1;
  buildtree(k << 1, l, mid);
  buildtree(k << 1 | 1, mid + 1, r);
  upd(k);
}
void add(long long k, long long x) {
  lazy[k] += x;
  mx[k] += x;
}
void pushdown(long long k) {
  if (!lazy[k]) return;
  add(k << 1, lazy[k]);
  add(k << 1 | 1, lazy[k]);
  lazy[k] = 0;
}
void change(long long k, long long l, long long r, long long L, long long R,
            long long x) {
  if (l >= L && r <= R) {
    add(k, x);
    return;
  }
  pushdown(k);
  long long mid = l + r >> 1;
  if (L <= mid) change(k << 1, l, mid, L, R, x);
  if (R > mid) change(k << 1 | 1, mid + 1, r, L, R, x);
  upd(k);
}
pair<long long, long long> merge(pair<long long, long long> x,
                                 pair<long long, long long> y) {
  return x.first > y.first ? x : y;
}
pair<long long, long long> find(long long k, long long l, long long r,
                                long long p) {
  if (l == r) return make_pair(mx[k], pos[k]);
  pushdown(k);
  long long mid = l + r >> 1;
  if (p <= mid) return find(k << 1, l, mid, p);
  return merge(make_pair(mx[k << 1], pos[k << 1]),
               find(k << 1 | 1, mid + 1, r, p));
}
signed main() {
  n = read();
  for (long long i = (long long)(1); i <= (long long)(n); i++) {
    long long x = read(), y = read(), w = read();
    if (y > x) swap(x, y);
    p[i] = (info){x, y, w};
    b[++cnt] = y;
    MX = max(MX, x);
  }
  sort(b + 1, b + cnt + 1);
  cnt = unique(b + 1, b + cnt + 1) - b - 1;
  for (long long i = (long long)(1); i <= (long long)(n); i++)
    p[i].y = lower_bound(b + 1, b + cnt + 1, p[i].y) - b;
  sort(p + 1, p + n + 1, cmp);
  buildtree(1, 1, cnt);
  long long ans = -inf;
  for (long long i = 1, j = 1; i <= n; i = j) {
    while (j <= n && p[j].x == p[i].x) {
      if (p[j].w != 0) change(1, 1, cnt, 1, p[j].y, p[j].w);
      j++;
    }
    long long alb = upper_bound(b + 1, b + cnt + 1, p[i].x) - b - 1;
    pair<long long, long long> res = find(1, 1, cnt, alb);
    if (res.first - p[i].x > ans) {
      ansx = res.second;
      ansy = p[i].x;
      ans = res.first - p[i].x;
    }
  }
  if (ans < 0) {
    ans = 0;
    ansx = ansy = MX + 1;
  }
  cout << ans << endl << ansx << " " << ansx << " " << ansy << " " << ansy;
}
