#include <bits/stdc++.h>
std::mt19937_64 rng(
    std::chrono::steady_clock::now().time_since_epoch().count());
using namespace std;
long long A1, B1, A2, B2;
int mtksz, stksz;
inline bool intersect(pair<long long, long long> p1,
                      pair<long long, long long> p2,
                      pair<long long, long long> p3) {
  A1 = p1.second - p2.second;
  B1 = p2.first - p1.first;
  if (B1 < 0) {
    A1 *= -1;
    B1 *= -1;
  }
  A2 = p1.second - p3.second;
  B2 = p3.first - p1.first;
  if (B2 < 0) {
    A2 *= -1;
    B2 *= -1;
  }
  return A1 * B2 > A2 * B1;
}
vector<pair<long double, long double> > stk(4005), mtk(4005);
int L, R, mid;
long double mini, cur, next, maxi;
int cnt = 0;
inline long double convex_min(long double z) {
  L = 0;
  R = stksz;
  mini = LLONG_MAX;
  while (L < R) {
    mid = (L + R) / 2;
    mini = min(mini, z * stk[mid].first + stk[mid].second);
    if (z * stk[mid].first + stk[mid].second <
        z * stk[mid + 1].first + stk[mid + 1].second) {
      mini = min(mini, z * stk[mid].first + stk[mid].second);
      R = mid;
    } else {
      mini = min(mini, z * stk[mid + 1].first + stk[mid + 1].second);
      L = mid + 1;
    }
  }
  return mini;
}
inline long double convex_max(long double z) {
  L = 0;
  R = mtksz;
  maxi = LLONG_MIN;
  while (L < R) {
    mid = (L + R) / 2;
    maxi = max(mini, z * mtk[mid].first + mtk[mid].second);
    if (z * mtk[mid].first + mtk[mid].second >
        z * mtk[mid + 1].first + mtk[mid + 1].second) {
      maxi = max(mini, z * mtk[mid].first + mtk[mid].second);
      R = mid;
    } else {
      maxi = max(mini, z * mtk[mid + 1].first + mtk[mid + 1].second);
      L = mid + 1;
    }
  }
  return maxi;
}
inline vector<pair<long double, long double> > merge_Intervals(
    vector<pair<long double, long double> > &forbid) {
  sort(forbid.begin(), forbid.end());
  vector<pair<long double, long double> > ss;
  if (forbid.size() == 0) return ss;
  ss.push_back(forbid[0]);
  for (int i = 0; i < forbid.size(); i++) {
    if (ss.back().second <= forbid[i].first)
      ss.push_back(forbid[i]);
    else if (ss.back().second < forbid[i].second) {
      ss.back().second = forbid[i].second;
    }
  }
  return ss;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    long long n;
    cin >> n;
    vector<pair<pair<long double, long double>, long double> > v;
    long double x, y, z;
    for (long long i = 0; i < n; i++) {
      cin >> x >> y >> z;
      v.push_back({{x, y}, z});
    }
    sort(v.begin(), v.end());
    long double ans = LLONG_MAX;
    vector<long double> xx;
    vector<pair<long double, long double> > forbid;
    long double z1, z2, den1, den2, pos = LLONG_MAX, neg = LLONG_MIN;
    vector<pair<long long, long long> > lines;
    for (long long gg = 0; gg < n; gg++) {
      lines.push_back({v[gg].second, v[gg].first.first});
      lines.push_back({v[gg].second, v[gg].first.second});
      for (long long i = gg + 1; i < n; i++) {
        if (v[i].second == v[gg].second) {
          continue;
        }
        z1 = (v[i].second - v[gg].second) /
             (v[i].first.first - v[gg].first.second);
        z2 = (v[gg].second - v[i].second) /
             (v[gg].first.first - v[i].first.second);
        den1 = (v[i].first.first - v[gg].first.second);
        den2 = (v[gg].first.first - v[i].first.second);
        if (z1 > 0 and z2 > 0 and den1 != 0 and den2 != 0)
          forbid.push_back({min(z1, z2), max(z1, z2)});
        else if (z1 < 0 and z2 < 0 and den2 != 0 and den1 != 0)
          forbid.push_back({min(z1, z2), max(z1, z2)});
        else if (den1 == 0.0 and den2 != 0) {
          if (z2 > 0)
            forbid.push_back({z2, pos});
          else
            forbid.push_back({neg, z2});
        } else if (den2 == 0.0 and den1 != 0) {
          if (z1 > 0)
            forbid.push_back({z1, pos});
          else
            forbid.push_back({neg, z1});
        } else {
          forbid.push_back({neg, min(z1, z2)});
          forbid.push_back({max(z1, z2), pos});
        }
      }
    }
    sort(lines.begin(), lines.end());
    reverse(lines.begin(), lines.end());
    stk[stksz] = lines[0];
    for (long long i = 1; i < lines.size(); i++) {
      while (stksz != -1 and stk[stksz].first == lines[i].first and
             stk[stksz].second > lines[i].second)
        stksz--;
      while (stksz >= 1 and intersect(stk[stksz - 1], stk[stksz], lines[i]))
        stksz--;
      if (stksz == -1) {
        stksz++;
        stk[stksz] = lines[i];
        continue;
      }
      if (stk[stksz].first != lines[i].first) {
        stksz++;
        stk[stksz] = lines[i];
      }
    }
    mtk[mtksz] = lines[0];
    for (long long i = 1; i < lines.size(); i++) {
      while (mtksz != -1 and mtk[mtksz].first == lines[i].first and
             mtk[mtksz].second < lines[i].second)
        mtksz--;
      while (mtksz >= 1 and !intersect(mtk[mtksz - 1], mtk[mtksz], lines[i]))
        mtksz--;
      if (mtksz == -1) {
        mtksz++;
        mtk[mtksz] = lines[i];
        continue;
      }
      if (mtk[mtksz].first != lines[i].first) {
        mtksz++;
        mtk[mtksz] = lines[i];
      }
    }
    vector<pair<long double, long double> > interval = merge_Intervals(forbid);
    for (int i = 0; i < interval.size(); i++) {
      xx.push_back(interval[i].first);
      xx.push_back(interval[i].second);
    }
    vector<long double>::iterator low, up;
    long long sz1, sz2;
    for (long long i = 0; i < xx.size(); i++) {
      if (xx[i] == pos or xx[i] == neg) continue;
      x = convex_min(-1 / xx[i]);
      y = convex_max(-1 / xx[i]);
      ans = min(ans, y - x);
    }
    long long rr = 1;
    for (long long i = 1; i < n; i++)
      if (v[i - 1].first.second > v[i].first.first) rr = 0;
    if (rr) {
      ans = min(ans, v[n - 1].first.second - v[0].first.first);
    }
    cout << setprecision(15) << ans;
  }
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}
