#include <bits/stdc++.h>
using namespace std;
const int inf = 2e9;
template <typename T>
inline T read() {
  T sum = 0, fl = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') fl = -1;
  for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
  return sum * fl;
}
const int maxn = 1e6 + 5;
int n, mx;
pair<int, int> id;
struct Node {
  int first, second, w;
} o[maxn];
int li[maxn];
long long ans;
bool operator<(const Node& a, const Node& b) { return a.second < b.second; }
namespace SEG {
pair<long long, int> tr[maxn << 2];
long long tag[maxn << 2];
inline pair<long long, int> Merge(const pair<long long, int>& a,
                                  const pair<long long, int>& b) {
  return a.first > b.first ? a : b;
}
inline void pushdown(int rt) {
  if (!tag[rt]) return;
  tr[(rt << 1)].first += tag[rt];
  tr[(rt << 1 | 1)].first += tag[rt];
  tag[(rt << 1)] += tag[rt];
  tag[(rt << 1 | 1)] += tag[rt];
  tag[rt] = 0;
}
void build(int rt, int l, int r) {
  if (l == r) return (void)(tr[rt] = make_pair(li[l], l));
  build((rt << 1), l, ((l + r) >> 1));
  build((rt << 1 | 1), ((l + r) >> 1) + 1, r);
  tr[rt] = Merge(tr[(rt << 1)], tr[(rt << 1 | 1)]);
}
void update(int rt, int l, int r, int ql, int qr, int v) {
  if (l >= ql && r <= qr) return (void)(tr[rt].first += v, tag[rt] += v);
  pushdown(rt);
  if (((l + r) >> 1) >= ql) update((rt << 1), l, ((l + r) >> 1), ql, qr, v);
  if (((l + r) >> 1) < qr)
    update((rt << 1 | 1), ((l + r) >> 1) + 1, r, ql, qr, v);
  tr[rt] = Merge(tr[(rt << 1)], tr[(rt << 1 | 1)]);
}
pair<long long, int> query(int rt, int l, int r, int ql, int qr) {
  if (l >= ql && r <= qr) return tr[rt];
  pair<long long, int> ans = make_pair(0, 0);
  pushdown(rt);
  if (((l + r) >> 1) >= ql)
    ans = Merge(ans, query((rt << 1), l, ((l + r) >> 1), ql, qr));
  if (((l + r) >> 1) < qr)
    ans = Merge(ans, query((rt << 1 | 1), ((l + r) >> 1) + 1, r, ql, qr));
  return ans;
}
}  // namespace SEG
void Solve() {
  n = read<int>();
  ans = 0;
  id = make_pair(2e9, 2e9);
  for (int i = 1; i <= n; ++i)
    o[i].first = read<int>(), o[i].second = read<int>(), o[i].w = read<int>();
  for (int i = 1; i <= n; ++i) li[i] = o[i].first, li[i + n] = o[i].second;
  sort(li + 1, li + n + n + 1);
  mx = unique(li + 1, li + n + n + 1) - li - 1;
  for (int i = 1; i <= n; ++i) {
    int first = min(o[i].first, o[i].second),
        second = max(o[i].first, o[i].second);
    o[i].first = lower_bound(li + 1, li + mx + 1, first) - li;
    o[i].second = lower_bound(li + 1, li + mx + 1, second) - li;
  }
  sort(o + 1, o + n + 1);
  SEG ::build(1, 1, mx);
  for (int i = 1; i <= n;) {
    do {
      SEG ::update(1, 1, mx, 1, o[i].first, o[i].w);
      ++i;
    } while (i <= n && o[i].second == o[i - 1].second);
    pair<long long, int> now = SEG ::query(1, 1, mx, 1, o[i - 1].second);
    int r = o[i - 1].second;
    if (now.first - li[r] > ans && now.second)
      ans = now.first - li[r], id = make_pair(li[now.second], li[r]);
  }
  printf("%lld\n%d %d %d %d\n", ans, id.first, id.first, id.second, id.second);
}
int main() {
  Solve();
  return 0;
}
