Jonathan has decided to attend a speed dating event! The event works by having the participant (Jonathan) rotate through a selection of tables where people will come and sit down. As everyone at the event is on a strict schedule, Jonathan will have 5 seconds of allotted time with each participant.
In the event, there are a total of participants each with their respective table. Jonathan knows that he should be at the participant's table at seconds, stay there for seconds and then leave to the next participant at seconds. Every table is initially empty and the participant that Jonathan is meeting will arrive at the table at exactly seconds. Jonathan starts his rotation at seconds and takes seconds to get from one table to the next. If Jonathan does not arrive at a table in time, the participant will leave and go home. If he arrives at an empty table, he will assume he is too late and move on with his schedule.
How many seconds does Jonathan spend with a participant?
Constraints
Input Specification
The first line will contain a single integer .
The second line will contain integers, such that where is when Jonathan should be at the table.
The third line will contain integers, such that where is the number of seconds it takes Jonathan to get to the table from his previous position.
Output Specification
A single integer representing the total number of seconds Jonathan was with any participant.
Sample Input 1
3
1 7 13
1 1 1
Sample Output 1
15
Sample Input 2
2
1 6
4 2
Sample Output 2
5
Comments