The Queue of Doubts
TIME LIMIT = 1 SEC.
- Everybody loves Praveen sir's classes. He explains stuff so well, one can't help but get engaged in the classes and listen to what he has to say. But every once in a while, there comes a difficult topic that he has to explain, and students get doubts. Praveen sir being the dedicated teacher that he is, wants to clear everyone's doubts.
He knows the total number of students who have doubts - N, and the number of doubts that each student has - Ni for the ith student. Praveen sir decides to form a queue, and clear 1 doubt of a student at a time. If the student has more doubts, then he goes back to the end of the queue and waits for his turn again. This applies to all students. Praveen sir takes 1 minute to clear 1 doubt. If a student has 0 doubts remaining, he goes back to his bench in the classroom.
For a given value T, find out the number of doubts remaining of the student in front of the queue at the Tth minute.
|The first line consists of two space-separated integers - N, T.
N lines follow, each line containing Ni - the number of doubts the ith student.
|A single line containing the number of doubts that the student in the front of the queue has at the Tth minute.|
- 1 ≤ N,T ≤ 1000
- 1 ≤ Ni ≤ 1000