#include <bits/stdc++.h>
using namespace std;
const int limite = 1000000;
int num;
double posicion[limite];
double velocidad[limite];
double entra[limite];
void calcula(vector<pair<double, double> > &lista, vector<double> &p,
             vector<double> &v, vector<double> &e) {
  posicion[0] = lista[0].first;
  velocidad[0] = lista[0].second;
  num = 1;
  for (int i = 1; i < int(lista.size()); i++) {
    double pos = lista[i].first;
    double vel = lista[i].second;
    if (vel < velocidad[num - 1]) {
      posicion[num] = pos;
      velocidad[num] = vel;
      entra[num] = (pos - posicion[num - 1]) / (velocidad[num - 1] - vel);
      while (num > 1 and entra[num] <= entra[num - 1]) {
        posicion[num - 1] = posicion[num];
        velocidad[num - 1] = velocidad[num];
        entra[num - 1] = entra[num];
        num--;
        entra[num] = (pos - posicion[num - 1]) / (velocidad[num - 1] - vel);
      }
      num++;
    }
  }
  p = v = e = vector<double>(num);
  for (int i = 0; i < num; i++) {
    p[i] = posicion[i];
    v[i] = velocidad[i];
    e[i] = entra[i];
  }
}
bool hayminimototal = false;
double minimototal;
void seccion(vector<pair<double, double> > &moveright,
             vector<pair<double, double> > &moveleft) {
  if (int(moveright.size()) == 0 or int(moveleft.size()) == 0) return;
  vector<double> pl, vl, el;
  calcula(moveleft, pl, vl, el);
  for (int i = 0; i < int(moveright.size()); i++) {
    moveright[i].first *= -1;
    moveright[i].second *= -1;
  }
  reverse(moveright.begin(), moveright.end());
  vector<double> pr, vr, er;
  calcula(moveright, pr, vr, er);
  for (int i = 0; i < int(pr.size()); i++) {
    pr[i] *= -1;
    vr[i] *= -1;
  }
  int il = 0;
  int ir = 0;
  for (;;) {
    double t = (pl[il] - pr[ir]) / (vr[ir] - vl[il]);
    if (ir < int(pr.size()) - 1 and er[ir + 1] < t) {
      if (il < int(pl.size()) - 1 and el[il + 1] < t) {
        if (er[ir + 1] < el[il + 1]) {
          ir++;
        } else {
          il++;
        }
      } else {
        ir++;
      }
    } else if (il < int(pl.size()) - 1 and el[il + 1] < t) {
      il++;
    } else {
      break;
    }
  }
  double t = (pl[il] - pr[ir]) / (vr[ir] - vl[il]);
  if (not hayminimototal or minimototal > t) {
    hayminimototal = true;
    minimototal = t;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(15);
  vector<vector<pair<double, double> > > move(2);
  int j = 0;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, v;
    cin >> x >> v;
    if (j == 0) {
      if (v > 0) {
        move[0].push_back(pair<double, double>(x, v));
      } else {
        j = 1;
        move[1].push_back(pair<double, double>(x, v));
        if (i == n - 1) seccion(move[0], move[1]);
      }
    } else if (j == 1) {
      if (v > 0) {
        seccion(move[0], move[1]);
        move = vector<vector<pair<double, double> > >(2);
        j = 0;
        move[0].push_back(pair<double, double>(x, v));
      } else {
        move[1].push_back(pair<double, double>(x, v));
        if (i == n - 1) seccion(move[0], move[1]);
      }
    }
  }
  if (hayminimototal)
    cout << minimototal << endl;
  else
    cout << -1 << endl;
}
