#include <bits/stdc++.h>
using namespace std;
long long int LIM = 1e6 + 10;
long long int MAXI = 1e6 + 10;
vector<pair<long long int, int> > tree(2 * LIM + LIM / 2);
vector<long long int> lazy1(2 * LIM + LIM / 2);
pair<long long int, int> combine(pair<long long int, int> a,
                                 pair<long long int, int> b) {
  if (a.first > b.first)
    return a;
  else
    return b;
}
void build(int node, int start, int end) {
  if (start == end) {
    tree[node] = pair<long long int, int>(0, start);
    return;
  }
  int mid = (start + end) / 2;
  build(node * 2, start, mid);
  build(node * 2 + 1, mid + 1, end);
}
void updateRange(long long int node, long long int start, long long int end,
                 long long int l, long long int r, long long int val) {
  if (lazy1[node] != 0) {
    tree[node].first += lazy1[node];
    if (start != end) {
      lazy1[node * 2] += lazy1[node];
      lazy1[node * 2 + 1] += lazy1[node];
    }
    lazy1[node] = 0;
  }
  if (start > end or start > r or end < l) return;
  if (start >= l and end <= r) {
    tree[node].first += val;
    if (start != end) {
      lazy1[node * 2] += val;
      lazy1[node * 2 + 1] += val;
    }
    return;
  }
  long long int mid = (start + end) / 2;
  updateRange(node * 2, start, mid, l, r, val);
  updateRange(node * 2 + 1, mid + 1, end, l, r, val);
  tree[node] = combine(tree[node * 2], tree[node * 2 + 1]);
}
pair<long long int, int> queryRange(long long int node, long long int start,
                                    long long int end, long long int l,
                                    long long int r) {
  if (start > end or start > r or end < l)
    return pair<long long int, int>(-1e17, -1);
  if (lazy1[node] != 0) {
    tree[node].first += lazy1[node];
    if (start != end) {
      lazy1[node * 2] += lazy1[node];
      lazy1[node * 2 + 1] += lazy1[node];
    }
    lazy1[node] = 0;
  }
  if (start >= l and end <= r) return tree[node];
  long long int mid = (start + end) / 2;
  pair<long long int, int> p1 = queryRange(node * 2, start, mid, l, r);
  pair<long long int, int> p2 = queryRange(node * 2 + 1, mid + 1, end, l, r);
  return combine(p1, p2);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  vector<pair<pair<long long int, int>, int> > arr(n + 1);
  set<int> x, y;
  for (long long int i = 1; i <= n; i++) {
    cin >> arr[i].first.first >> arr[i].first.second >> arr[i].second;
    arr[i].first.first++;
    arr[i].first.second++;
    x.insert(arr[i].first.first);
    y.insert(arr[i].first.second);
  }
  set<int> iterate;
  iterate.insert(MAXI);
  map<int, int> x1, y1;
  long long int x2 = 1, y2 = 1;
  for (auto it = x.begin(); it != x.end(); it++) {
    x1[*it] = x2++;
    iterate.insert(*it);
  }
  for (auto it = y.begin(); it != y.end(); it++) {
    y1[*it] = y2++;
    iterate.insert(*it);
  }
  vector<int> iter(1);
  map<int, int> pos;
  long long int counter2 = 1;
  for (auto it = iterate.begin(); it != iterate.end(); it++) {
    pos[*it] = counter2++;
    iter.push_back(*it);
  }
  vector<vector<long long int> > points(LIM);
  vector<long long int> maxi(LIM);
  for (long long int i = 1; i <= n; i++) {
    long long int x = arr[i].first.first;
    long long int y = arr[i].first.second;
    if (x < y) {
      points[pos[x]].push_back(i);
      maxi[i] = y;
    } else {
      points[pos[y]].push_back(i);
      maxi[i] = x;
    }
  }
  long long int num = (long long int)iter.size() - 1;
  long long int ans = 0;
  long long int x3 = 0, y3 = 0;
  while (points[pos[x3] + 1].size() > 0) {
    x3++;
    y3++;
  }
  MAXI = num;
  build(1, 1, MAXI);
  for (long long int i = num - 1; i >= 1; i--) {
    int val = iter[i] - iter[i + 1];
    updateRange(1, 1, MAXI, i + 1, MAXI, val);
    long long int X = iter[i];
    for (long long int j = 0; j < points[pos[X]].size(); j++) {
      long long int val = arr[points[pos[X]][j]].second;
      int y = maxi[points[pos[X]][j]];
      updateRange(1, 1, MAXI, pos[y], MAXI, val);
    }
    pair<long long int, int> temp = queryRange(1, 1, MAXI, i, MAXI);
    if (temp.first > ans) {
      ans = temp.first;
      x3 = iter[i] - 1;
      y3 = iter[temp.second] - 1;
    }
  }
  cout << ans << endl;
  cout << x3 << " " << x3 << " " << y3 << " " << y3 << endl;
  return 0;
}
