시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB31161651.613%

문제

T1 Ashley is training for another programming contest on Brandon's Online Judge. Brandon's Online Judge still has the same feature which allows Ashley's coach, Tom, to load in a list of problems for Ashley to work on.

Tom has curated some problems for Ashley to work on. Each problem is parameterized by "implementation difficulty" and "thinking difficulty", both of which are positive integers. Ashley must solve them in order.

Ashley starts out with a given implementation skill and thinking skill level. Ashley can solve a problem if and only if her implementation skill level is greater than or equal to the implementation difficulty of the problem, and her thinking skill level is greater than or equal to the thinking difficulty of the problem. After solving a problem, exactly one of her implementation skill level and thinking skill level increases by $1$, and Ashley can pick which increases.

Compute the minimum possible sum of implementation and thinking skill levels that Ashley can start out with such that she can solve all the problems on Tom's list in order.

입력

The first line contains a single integer $n$ ($1 \le n \le 50$).

The next $n$ lines each contain two integers, $i$ and $t$ $(1 \le i, t \le 10^9)$, representing the implementation and thinking difficulties of one of the problems on Tom's list.

The problems are presented in the order that Ashley must solve them.

출력

Output a single integer, the minimum possible sum of implementation and thinking skill levels that Ashley can start out with such that she can solve all the problems on Tom's list in order.

예제 입력 1

3
4 4
5 1
1 5

예제 출력 1

8

예제 입력 2

3
4 4
1 6
6 1

예제 출력 2

10

예제 입력 3

2
33 33
34 34

예제 출력 3

67