#include<stdio.h>
int main()
{
int x[100000][2];
int i,t,save,c;
int q=0,sum1,sum2=0;
int rat;
while(t--)
{scanf("%d%d",x
[q
][0],x
[q
][1]); sum2+=x[q][1];
save=x[q][0];
rat=x[q][1];
c=q;
for(i=0;i<=q;i++)
{
if(x[i][0]>save)
{while(c>i)
{x[c][0]=x[c-1][0];
x[c][1]=x[--c][1];
}
x[i][0]=save;
x[i][1]=rat;
}
}
for(i=0;i<=q/2;i++)
sum1+=x[i][1];
if(2*sum1>sum2)
else
}
q++;
}
I2luY2x1ZGU8c3RkaW8uaD4KCmludCBtYWluKCkKewppbnQgeFsxMDAwMDBdWzJdOwppbnQgaSx0LHNhdmUsYzsKaW50IHE9MCxzdW0xLHN1bTI9MDsKaW50IHJhdDsKc2NhbmYoIiVkIix0KTsKd2hpbGUodC0tKQp7c2NhbmYoIiVkJWQiLHhbcV1bMF0seFtxXVsxXSk7CiAgICBzdW0yKz14W3FdWzFdOwogICAgc2F2ZT14W3FdWzBdOwogICAgcmF0PXhbcV1bMV07CiAgICBjPXE7CiAgICBmb3IoaT0wO2k8PXE7aSsrKQogICAgewogICAgaWYoeFtpXVswXT5zYXZlKQogICAgICAgIHt3aGlsZShjPmkpCiAgICAgICAgICAgIHt4W2NdWzBdPXhbYy0xXVswXTsKICAgICAgICAgICAgeFtjXVsxXT14Wy0tY11bMV07CiAgICAgICAgICAgIH0KICAgICAgICB4W2ldWzBdPXNhdmU7CiAgICAgICAgeFtpXVsxXT1yYXQ7CiAgICAgICAgfQogICAgfQoKICAgIGZvcihpPTA7aTw9cS8yO2krKykKICAgIHN1bTErPXhbaV1bMV07CiAgICBpZigyKnN1bTE+c3VtMikKICAgIHByaW50ZigiJWQiLDIqc3VtMS1zdW0yKTsKICAgIGVsc2UKICAgIHByaW50ZigiJWQiLHN1bTItMipzdW0xKTsKICAgIH0KcSsrOwp9Cgo=