#include <bits/stdc++.h>
using namespace std;
int xx[1000005], yy[1000005], cc[1000005];
vector<pair<int, int> > vec[1000005];
set<int> se;
map<int, int> ma;
int inv[1000005];
struct segTree {
  int n;
  vector<pair<long long, int> > tree;
  vector<long long> lazy;
  segTree(int n) : n(n), tree(4 * n, {0, 0}), lazy(4 * n, 0) {}
  void treeSetup(int node, int l, int r) {
    if (l == r) {
      tree[node].second = l;
      return;
    }
    int mid = (l + r) >> 1;
    treeSetup(2 * node, l, mid);
    treeSetup(2 * node + 1, mid + 1, r);
    tree[node] = max(tree[2 * node], tree[2 * node + 1]);
  }
  void setup() { treeSetup(1, 1, n); }
  void propagate(int node, int l, int r) {
    tree[node].first += lazy[node];
    if (l != r) lazy[2 * node] += lazy[node], lazy[2 * node + 1] += lazy[node];
    lazy[node] = 0;
  }
  void treeUpdate(int node, int l, int r, int u, int v, long long val) {
    int mid = (l + r) >> 1;
    propagate(node, l, r);
    if (l > v || r < u) return;
    if (l >= u && r <= v) {
      lazy[node] += val;
      propagate(node, l, r);
      return;
    }
    treeUpdate(2 * node, l, mid, u, v, val);
    treeUpdate(2 * node + 1, mid + 1, r, u, v, val);
    tree[node] = max(tree[2 * node], tree[2 * node + 1]);
  }
  void update(int l, int r, long long val) { treeUpdate(1, 1, n, l, r, val); }
  pair<long long, int> treeQuery(int node, int l, int r, int u, int v) {
    int mid = (l + r) >> 1;
    propagate(node, l, r);
    if (l > v || r < u) return {-1, -1};
    if (l >= u && r <= v) return tree[node];
    return max(treeQuery(2 * node, l, mid, u, v),
               treeQuery(2 * node + 1, mid + 1, r, u, v));
  }
  pair<long long, int> query(int l, int r) { return treeQuery(1, 1, n, l, r); }
};
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d %d", xx + i, yy + i, cc + i);
    se.insert(xx[i]);
    se.insert(yy[i]);
  }
  int tot = 0;
  for (int x : se) {
    ma[x] = ++tot;
    inv[tot] = x;
  }
  for (int i = 1; i <= n; i++) {
    int x = min(xx[i], yy[i]), y = max(xx[i], yy[i]);
    x = ma[x], y = ma[y];
    int c = cc[i];
    vec[x].push_back({y, c});
  }
  segTree tree(tot);
  tree.setup();
  long long ans = 0;
  int ansx = 2000000000, ansy = 2000000000;
  for (int i = tot; i; i--) {
    for (pair<int, int> p : vec[i]) {
      int r = p.first, c = p.second;
      tree.update(r, tot, c);
    }
    pair<long long, int> tmp = tree.query(i, tot);
    if (tmp.first > ans) ans = tmp.first, ansx = inv[i], ansy = inv[tmp.second];
    tree.update(i, tot, inv[i - 1] - inv[i]);
  }
  printf("%lld\n", ans);
  printf("%d %d %d %d\n", ansx, ansx, ansy, ansy);
  return 0;
}
