Apples, a specialty of Gyeongsangbuk-do, were assigned to several schools so that the students could share them. The number of assigned apples can differ from school to school, and so can the number of students. Each school gives every one of its students the same number of apples and wants as few apples as possible left over. Students at different schools can receive different numbers of apples.
For example, suppose the student counts and the assigned apple counts of five schools are as follows.
| School | A | B | C | D | E |
|---|---|---|---|---|---|
| Students | 24 | 13 | 5 | 23 | 7 |
| Apples | 52 | 22 | 53 | 10 | 70 |
School A gives two apples to every student and 4 apples are left over. School B gives one apple to every student and 9 apples are left over. In the same way school C is left with 3 apples, school D with 10 apples, and school E with 0 apples, so the total number of leftover apples is 4+9+3+10+0=26.
Given the number of students and the number of assigned apples at each school, write a program that computes the total number of apples left over after the students receive theirs.
The first line contains an integer N (1≤N≤100), the number of schools. Each of the next N lines contains two integers, the number of students at that school and the number of apples assigned to it. Both the student count and the apple count are between 1 and 100.
Print one integer, the total number of leftover apples.