#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
long long MOD = 1000000007;
long double EPS = 1e-9;
long long binpow(long long b, long long p, long long mod) {
  long long ans = 1;
  b %= mod;
  for (; p; p >>= 1) {
    if (p & 1) ans = ans * b % mod;
    b = b * b % mod;
  }
  return ans;
}
void pre() {}
map<long long, long long> compmp;
long long rev[500100];
long long compcnt;
vector<long long> compress(vector<long long> arr) {
  for (auto v : arr) compmp[v];
  for (auto v : compmp) {
    compmp[v.first] = compcnt++;
    rev[compcnt - 1] = v.first;
  }
  for (long long i = 0; i < (arr.size()); ++i) arr[i] = compmp[arr[i]];
  return arr;
}
void compreset() {
  compmp.clear();
  compcnt = 0;
}
vector<long long> ender;
vector<long long> pos;
vector<long long> sortedpos;
pair<long long, long long> t[4000100];
long long lazy[4000100];
void push(long long id, long long l, long long r) {
  if (lazy[id] != 0) {
    t[id].first += lazy[id];
    if (l != r) {
      lazy[id << 1] += lazy[id];
      lazy[id << 1 | 1] += lazy[id];
    }
    lazy[id] = 0;
  }
}
void build(long long id, long long l, long long r) {
  lazy[id] = 0;
  if (l == r) {
    t[id] = make_pair(-sortedpos[l], sortedpos[l]);
    return;
  }
  build(id << 1, l, ((l + r) >> 1));
  build(id << 1 | 1, ((l + r) >> 1) + 1, r);
  t[id] = max(t[id << 1], t[id << 1 | 1]);
}
void update(long long id, long long l, long long r, long long lq, long long rq,
            long long val) {
  push(id, l, r);
  if (l > r || lq > r || l > rq) return;
  if (lq <= l && r <= rq) {
    lazy[id] += val;
    push(id, l, r);
    return;
  }
  update(id << 1, l, ((l + r) >> 1), lq, rq, val);
  update(id << 1 | 1, ((l + r) >> 1) + 1, r, lq, rq, val);
  t[id] = max(t[id << 1], t[id << 1 | 1]);
}
pair<long long, long long> get(long long id, long long l, long long r,
                               long long lq, long long rq) {
  push(id, l, r);
  if (l > r || lq > r || l > rq) return make_pair(-MOD * MOD, lq);
  if (lq <= l && r <= rq) {
    return t[id];
  }
  return max(get(id << 1, l, ((l + r) >> 1), lq, rq),
             get(id << 1 | 1, ((l + r) >> 1) + 1, r, lq, rq));
}
using iii = pair<pair<long long, long long>, long long>;
vector<iii> arr;
void activate(long long i) {
  update(1, 0, compcnt - 1, pos[i], compcnt - 1, arr[i].second);
}
void solve() {
  long long n;
  cin >> n;
  arr.resize(n);
  for (long long i = 0; i < (n); ++i) {
    cin >> arr[i].first.first >> arr[i].first.second >> arr[i].second;
  }
  vector<pair<long long, long long> > activation;
  for (long long i = 0; i < (n); ++i) {
    activation.emplace_back(
        make_pair(min(arr[i].first.first, arr[i].first.second), i));
  }
  sort((activation).begin(), (activation).end());
  for (long long i = 0; i < (n); ++i) {
    ender.emplace_back(max(arr[i].first.first, arr[i].first.second));
  }
  pos = compress(ender);
  {};
  sortedpos.resize(compcnt);
  for (long long i = 0; i < (n); ++i) {
    sortedpos[pos[i]] = ender[i];
  }
  {};
  reverse((activation).begin(), (activation).end());
  build(1, 0, compcnt - 1);
  {};
  pair<long long, pair<long long, long long> > best =
      make_pair(0, make_pair(MOD, MOD));
  for (long long i = 0; i < (activation.size()); ++i) {
    long long j = i;
    while (j < activation.size() &&
           activation[j].first == activation[i].first) {
      activate(activation[j].second);
      j++;
    }
    long long posinsorted = lower_bound((sortedpos).begin(), (sortedpos).end(),
                                        activation[i].first) -
                            sortedpos.begin();
    pair<long long, long long> rangebest =
        get(1, 0, compcnt - 1, posinsorted, compcnt - 1);
    rangebest.first += activation[i].first;
    (best = max((best),
                (make_pair(rangebest.first,
                           make_pair(activation[i].first, rangebest.second)))));
    i = j - 1;
  }
  cout << best.first << '\n';
  cout << best.second.first << " " << best.second.first << " "
       << best.second.second << " " << best.second.second << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  pre();
  long long _t = 1;
  for (long long i = 1; i <= _t; i++) {
    solve();
  }
}
