#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
const db EPS = 1e-9;
const db INF = 1e47;
vector<pair<db, LL>> compress(vector<pair<db, LL>> vec)
{
sort(ALL(vec));
vector<pair<db, LL>> res;
for (auto [p, c] : vec)
{
if (res.empty() || abs(res.back().F - p) > EPS)
{
res.PB({p, c});
}
else
{
res.back().S += c;
}
}
return res;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector<pair<db, LL>> vec(n);
for (auto& [p, c] : vec)
cin >> p >> c;
vec = compress(vec);
vector<LL> sx[2];
vector<db> sxx[2];
FOR(j, 0, 2)
{
sx[j].resize(n + 1);
sxx[j].resize(n + 1);
FOR(i, 0, n)
{
auto& [p, c] = vec[i];
sx[j][i + 1] = sx[j][i] + c;
db x = abs(1 - p) < EPS ? INF : 1 / (1 - p);
sxx[j][i + 1] = sx[j][i] * x;
p = 1 - p;
}
reverse(ALL(vec));
}
reverse(ALL(sx[1]));
reverse(ALL(sxx[1]));
FOR(k, 0, 2)
{
FOR(j, 0, n + 1)
{
int i = lower_bound(sxx[0].begin(), sxx[0].begin() + i, sxx[1][j]);
}
}
return 0;
}