Under construction

Still being built. Things may change

PE Class

Interview

Time limit1sMemory limit1024 MB

Summary
Students are sorted by height within each sex group, boys first, and the task is to find the largest height gap between neighbors in the row.
Level

Easy2 of 10

Topics
Sorting, Implementation
Solved
No attempts yet

Problem

During PE class, the coach Andrey Sergeevich lines up the students in a single row. The boys stand first, followed by the girls. The boys are arranged in descending order of height, and the girls are too. So the shortest boy is directly followed by the tallest girl.

Andrey Sergeevich wants to know the largest height difference between two students standing next to each other. Write a program that answers this question.

Input

The first line contains an integer nn, the number of students in the class (2≤n≤502 \le n \le 50). Each of the next nn lines contains two integers aia_i and hih_i, the sex and height in centimeters of the ii-th student (100≤hi≤200100 \le h_i \le 200). ai=0a_i = 0 means the ii-th student is a boy, and ai=1a_i = 1 means the ii-th student is a girl.

Output

Print one integer, the largest height difference between two students standing next to each other after they line up for PE class.

Examples1

  1. Example 1

    Input
    6
    0 120
    1 130
    1 142
    1 115
    0 145
    0 134
    
    Expected output
    22