All-Berland programming contest comes to an end. In total, _n_ teams participated in it. Like in ACM-ICPC, current results stopped refreshing one hour before the contest ends. So at the Award Ceremony, results are partially known. For each team the value _a__i_ is given — the number of points the _i_\-th team has earned before the last hour of the contest. Besides that, the Jury has evaluated all submissions sent during the last hour and knows values _d__i_ — the number of points earned by the _i_\-th team during the last hour (these values can be negative, which means that a team can lose points).
Before the contest, each team got unique id from 1 to _n_. According to the contest rules, a team with more points takes a higher place. If two or more teams have equal number of points, the team with lower id will take the higher place. So no two teams can share the same place.
The Award Ceremony proceeds in the following way. At the beginning of the ceremony, a large screen shows the results for the time moment "one hour before the end", which means that the _i_\-th team has _a__i_ points. Then the Jury unfreezes results of the teams one by one in some order. When result of the _j_\-th team is unfrozen, its score changes from _a__j_ to _a__j_ + _d__j_. At this time the table of results is modified and the place of the team can change. The unfreezing of the _j_\-th team is followed by the applause from the audience with duration of |_x__j_ - _y__j_| seconds, where _x__j_ is the place of the _j_\-th team before unfreezing and _y__j_ is the place right after the unfreezing. For example, if the team does not change the place, there is no applause from the audience. As you can see, during the Award Ceremony, each team will be unfrozen exactly once.
Your task is to find such an order to unfreeze all the teams that the total duration of applause is maximum possible.
## Input
The first line of the input file contains a single integer _n_ (1 ≤ _n_ ≤ 100) — the number of teams.
Each of the next _n_ lines contains two integers _a__i_ and _d__i_ (1 ≤ _a__i_ ≤ 100, - 100 ≤ _d__i_ ≤ 100) — the number of points the _i_\-th team has earned before the last hour of the contest and the number of points earned by this team during the last hour. It is possible that after unfreezing a team will have a negative score.
## Output
Print the only integer — maximal total applause duration in seconds if the Jury can choose any order of the teams to unfreeze.
[samples]
## Note
In the first example the initial standings are:
1. Team 2, 52 points
2. Team 1, 17 points
3. Team 4, 6 points
4. Team 3, 1 point
Here any order of unfreezing the teams leads to 4 seconds of applause in total. For example, let's unfreeze teams in their order from the Team 1 to the Team 4.
After the Team 1 became unfrozen the standings are:
1. Team 2, 52 points
2. Team 4, 6 points
3. Team 1, 3 points
4. Team 3, 1 point
So there is 1 second of applause, because the difference between old and new places |2 - 3| = 1.
After the Team 2 became unfrozen the standings are:
1. Team 2, 47 points
2. Team 4, 6 points
3. Team 1, 3 points
4. Team 3, 1 point
The place of the Team 2 has not changed, so no applause during unfreezing.
After the Team 3 became unfrozen the standings are:
1. Team 3, 53 point
2. Team 2, 47 points
3. Team 4, 6 points
4. Team 1, 3 points
The place of the Team 3 has changed from 4 to 1, so the duration of applause is |4 - 1| = 3.
The unfreezing of the Team 4 has not changed any place because _d_4 = 0.
Therefore, the total duration of applause is 1 + 0 + 3 + 0 = 4 seconds.
全俄罗斯编程竞赛结束了。共有 #cf_span[n] 支队伍参赛。与 ACM-ICPC 类似,比赛结束前一小时,当前排名停止刷新。因此,在颁奖典礼开始时,结果仅部分公开。对于每支队伍,给定值 #cf_span[ai] —— 第 #cf_span[i] 支队伍在比赛最后一小时前获得的分数。此外,评审团已评估了最后一小时的所有提交,并知晓值 #cf_span[di] —— 第 #cf_span[i] 支队伍在最后一小时获得的分数(这些值可能为负,意味着队伍可能失分)。
比赛前,每支队伍被赋予从 1 到 #cf_span[n] 的唯一编号。根据比赛规则,分数更高的队伍排名更高。若两支或更多队伍分数相同,则编号较小的队伍排名更高。因此,没有两支队伍会共享同一排名。
颁奖典礼按如下方式进行:典礼开始时,大屏幕显示“比赛结束前一小时”的排名,即第 #cf_span[i] 支队伍拥有 #cf_span[ai] 分。随后,评审团按某种顺序逐个解冻各队伍的成绩。当第 #cf_span[j] 支队伍的成绩被解冻时,其分数从 #cf_span[aj] 变为 #cf_span[aj + dj]。此时,排名表被更新,该队伍的排名可能发生变动。第 #cf_span[j] 支队伍的解冻后,观众会鼓掌 #cf_span[|xj - yj|] 秒,其中 #cf_span[xj] 是解冻前该队伍的排名,#cf_span[yj] 是解冻后该队伍的排名。例如,若队伍排名未变,则观众无掌声。可见,在颁奖典礼期间,每支队伍恰好被解冻一次。
你的任务是找到一种解冻所有队伍的顺序,使得观众掌声总时长最大化。
输入文件的第一行包含一个整数 #cf_span[n] (#cf_span[1 ≤ n ≤ 100]) —— 队伍数量。
接下来的 #cf_span[n] 行,每行包含两个整数 #cf_span[ai] 和 #cf_span[di] (#cf_span[1 ≤ ai ≤ 100], #cf_span[ - 100 ≤ di ≤ 100]) —— 第 #cf_span[i] 支队伍在比赛最后一小时前获得的分数,以及在最后一小时获得的分数。解冻后,队伍的分数可能为负。
仅输出一个整数 —— 若评审团可任意选择解冻顺序,最大可能的掌声总时长(秒)。
在第一个例子中,初始排名为:
任何解冻顺序都会导致总掌声时长为 4 秒。例如,按从 Team 1 到 Team 4 的顺序解冻队伍。
Team 1 解冻后,排名变为:
因此有 1 秒掌声,因为旧排名与新排名的差为 #cf_span[|2 - 3| = 1]。
Team 2 解冻后,排名变为:
Team 2 的排名未变,因此解冻时无掌声。
Team 3 解冻后,排名变为:
Team 3 的排名从第 4 名变为第 1 名,因此掌声时长为 #cf_span[|4 - 1| = 3]。
Team 4 解冻时排名未变,因为 #cf_span[d4 = 0]。
因此,掌声总时长为 #cf_span[1 + 0 + 3 + 0 = 4] 秒。
## Input
输入文件的第一行包含一个整数 #cf_span[n] (#cf_span[1 ≤ n ≤ 100]) —— 队伍数量。接下来的 #cf_span[n] 行,每行包含两个整数 #cf_span[ai] 和 #cf_span[di] (#cf_span[1 ≤ ai ≤ 100], #cf_span[ - 100 ≤ di ≤ 100]) —— 第 #cf_span[i] 支队伍在比赛最后一小时前获得的分数,以及在最后一小时获得的分数。解冻后,队伍的分数可能为负。
## Output
仅输出一个整数 —— 若评审团可任意选择解冻顺序,最大可能的掌声总时长(秒)。
[samples]
## Note
在第一个例子中,初始排名为:
Team 2,52 分
Team 1,17 分
Team 4,6 分
Team 3,1 分
任何解冻顺序都会导致总掌声时长为 4 秒。例如,按从 Team 1 到 Team 4 的顺序解冻队伍。
Team 1 解冻后,排名变为:
Team 2,52 分
Team 4,6 分
Team 1,3 分
Team 3,1 分
因此有 1 秒掌声,因为旧排名与新排名的差为 #cf_span[|2 - 3| = 1]。
Team 2 解冻后,排名变为:
Team 2,47 分
Team 4,6 分
Team 1,3 分
Team 3,1 分
Team 2 的排名未变,因此解冻时无掌声。
Team 3 解冻后,排名变为:
Team 3,53 分
Team 2,47 分
Team 4,6 分
Team 1,3 分
Team 3 的排名从第 4 名变为第 1 名,因此掌声时长为 #cf_span[|4 - 1| = 3]。
Team 4 解冻时排名未变,因为 #cf_span[d4 = 0]。
因此,掌声总时长为 #cf_span[1 + 0 + 3 + 0 = 4] 秒。
**Definitions**
Let $ n \in \mathbb{Z} $ be the number of teams.
For each team $ i \in \{1, \dots, n\} $:
- $ a_i \in \mathbb{Z} $: points before the last hour.
- $ d_i \in \mathbb{Z} $: points gained during the last hour.
- Final score: $ s_i = a_i + d_i $.
- Team ID: $ i $ (unique, from 1 to $ n $).
**Ranking Rule**
Teams are ranked by:
1. Descending order of $ s_i $.
2. Ascending order of ID $ i $ in case of ties.
Thus, rank $ r_i $ is the position of team $ i $ in this sorted order (1 = highest).
**Initial State**
Before any unfreezing, the score of team $ i $ is $ a_i $, so initial rank is $ r_i^{(0)} = \text{rank of } i \text{ under scores } \{a_1, \dots, a_n\} $.
**Unfreezing Process**
Let $ \pi \in S_n $ be a permutation representing the order of unfreezing.
At step $ k $, team $ \pi(k) $ is unfrozen:
- Its score updates from $ a_{\pi(k)} $ to $ s_{\pi(k)} = a_{\pi(k)} + d_{\pi(k)} $.
- Its rank changes from $ r_{\pi(k)}^{(k-1)} $ (before unfreezing) to $ r_{\pi(k)}^{(k)} $ (after unfreezing).
- Applause duration: $ \left| r_{\pi(k)}^{(k-1)} - r_{\pi(k)}^{(k)} \right| $.
**Objective**
Maximize total applause:
$$
\max_{\pi \in S_n} \sum_{k=1}^{n} \left| r_{\pi(k)}^{(k-1)} - r_{\pi(k)}^{(k)} \right|
$$
where ranks are recomputed after each unfreezing step under the updated score vector.