some large corporation Polycarpus work short message service center smsc the center task send sort crucial information Polycarpus decide check efficiency smsc for ask statistic performance smsc period time in end Polycarpus get list n task go smsc corporation each task describe time receive smsc number text message send More formally ith task describe integer ti ci receive time second number text message correspondinglypolycarpus know SMSC send text message second the SMSC use queue organize work consider time moment x smsc work moment follow if time moment x queue SMSC send message queue smsc get message head queue Otherwise do not send message time moment x if time moment x SMSC receive task add queue message task SMSC add message tail queue note message task send time moment x that s decision send message point 1 add message queue give information n task Polycarpus want count value time text message send maximum size queue time Help count characteristic need evaluate efficiency SMSC