Xiao Ming likes history very much. One day, xiao Ming went back to the past. He returned to the qing dynasty and became a crown prince.
He was excited to finally have the chance to become emperor! But we all know that emperors in ancient times had many sons,
They are all competitors of xiao Ming, so he needs others' support. Xiao Ming knows history very well.
He knew who the other princes' supporters were and how much money was needed to bribe their supporters
You don't want to spend too much money, you want to spend the least amount of money to get support to become emperor, to be emperor, you need to have the most supporters (more than any other prince).
输入描述:
First line contains one integer n (1 <= n <= 100000)——Total number of supporters.Each line below describes a supporterand contains two integers ai and bi (0 <= ai <= 100000 , 0 <= bi <= 10000)
ai and bi indicate the prince of each supporter and the money he needs to bribe.You are the prince 0((so if a supporters wants to vote for you, ai is equal to zero, in which case bi will also be equal to zero))
输出描述:
Print one integer——smallest amount of money you need to spend to become the emperor