#include <bits/stdc++.h>
using namespace std;
const long long inf = (long long)1e18;
const long long mod = (long long)1e9 + 7;
const double eps = (double)1e-9;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};
const int N = 1000500;
int n, x[N], y[N], c[N], ansl, ansr, z[N], m;
vector<int> g[N];
long long tt[4 * N], ans;
pair<long long, int> t[4 * N];
map<int, int> M;
set<int> second;
void push(int v) {
  t[v + v].first += tt[v];
  tt[v + v] += tt[v];
  t[v + v + 1].first += tt[v];
  tt[v + v + 1] += tt[v];
  tt[v] = 0;
}
void build(int v, int tl, int tr) {
  if (tl == tr) {
    t[v].first = z[tl];
    t[v].second = tl;
    return;
  }
  int tm = (tl + tr) >> 1;
  build(v + v, tl, tm);
  build(v + v + 1, tm + 1, tr);
  if (t[v + v].first > t[v + v + 1].first)
    t[v] = t[v + v];
  else
    t[v] = t[v + v + 1];
}
void upd(int v, int tl, int tr, int l, int r, int val) {
  if (l > r) return;
  if (tl == l && tr == r) {
    t[v].first += val;
    tt[v] += val;
    return;
  }
  push(v);
  int tm = (tl + tr) >> 1;
  upd(v + v, tl, tm, l, min(r, tm), val);
  upd(v + v + 1, tm + 1, tr, max(l, tm + 1), r, val);
  if (t[v + v].first > t[v + v + 1].first)
    t[v] = t[v + v];
  else
    t[v] = t[v + v + 1];
}
pair<long long, int> get(int v, int tl, int tr, int l, int r) {
  if (l > r) return make_pair(0, 0);
  if (tl == l && tr == r) return t[v];
  push(v);
  int tm = (tl + tr) >> 1;
  pair<long long, int> L = get(v + v, tl, tm, l, min(r, tm));
  pair<long long, int> R = get(v + v + 1, tm + 1, tr, max(l, tm + 1), r);
  if (L.first > R.first) return L;
  return R;
}
int main() {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> x[i] >> y[i] >> c[i];
    second.insert(x[i]);
    second.insert(y[i]);
  }
  for (int i : second) {
    M[i] = ++m;
    z[m] = i;
  }
  build(1, 1, m);
  for (int i = 1; i <= n; ++i) {
    g[M[max(x[i], y[i])]].push_back(i);
  }
  for (int i = 1; i <= m; ++i) {
    for (int j : g[i]) upd(1, 1, m, 1, M[min(x[j], y[j])], c[j]);
    pair<long long, int> pr = get(1, 1, m, 1, i);
    if (pr.first - z[i] > ans) {
      ans = pr.first - z[i];
      ansl = pr.second, ansr = i;
    }
  }
  if (ans)
    ansl = z[ansl], ansr = z[ansr];
  else
    ansl = (int)2e9, ansr = (int)2e9;
  cout << ans << endl;
  cout << ansl << " " << ansl << " " << ansr << " " << ansr << endl;
  return 0;
}
