from sys import stdin from heapq import heappush as push from heapq import heappop as pop import sys #sys.setrecursionlimit(20) n = int(stdin.readline().strip()) torq = 0 p,w,moved = [0]*n,[0]*n,[0]*n for i in range(n): p[i], w[i] = map(int, stdin.readline().split()) torq += p[i] * w[i] if torq < 0: for i in range(n//2): p[i],w[i],p[n-1-i],w[n-1-i] = -p[n-1-i],w[n-1-i],-p[i],w[i] torq = -torq if n&1: p[n//2] = -p[n//2] q = [] # DSU too :( par = [-1 for i in range(n)] mn = [i for i in range(n)] def find(x): global par #print(par, x) if par[x] < 0: return x par[x] = find(par[x]) return par[x] def merge(x, y): global par global mn #print(par, x, y) x = find(x) y = find(y) if par[x] > par[y]: x,y = y,x par[x] += par[y] par[y] = x mn[x] = min(mn[x], mn[y]) for i in range(n): push(q, [-w[i], i, 1]) # cur effective weight, index, the total people ans = 0 while 1: x = pop(q) ew,i,population = -x[0],x[1],x[2] # Can move infinitely if i == 0: ans += torq / ew break # Skip if this moved already if moved[i]: continue moved[i] = 1 # Determine the distance this group can move j = mn[find(i-1)] nextX = p[j] maxDist = p[i] - nextX if torq < maxDist * ew * population: # can we move enough ans += torq / ew break # Move to the next group torq -= maxDist * ew * population ans += maxDist * population merge(i,j) w[j] += w[i] sz = -par[find(i)] push(q, [-w[j] / sz, j, sz]) print(ans)