Two friends are on the coordinate axis _Ox_ in points with integer coordinates. One of them is in the point _x_1 = _a_, another one is in the point _x_2 = _b_.
Each of the friends can move by one along the line in any direction unlimited number of times. When a friend moves, the tiredness of a friend changes according to the following rules: the first move increases the tiredness by 1, the second move increases the tiredness by 2, the third — by 3 and so on. For example, if a friend moves first to the left, then to the right (returning to the same point), and then again to the left his tiredness becomes equal to 1 + 2 + 3 = 6.
The friends want to meet in a integer point. Determine the minimum total tiredness they should gain, if they meet in the same point.
## Input
The first line contains a single integer _a_ (1 ≤ _a_ ≤ 1000) — the initial position of the first friend.
The second line contains a single integer _b_ (1 ≤ _b_ ≤ 1000) — the initial position of the second friend.
It is guaranteed that _a_ ≠ _b_.
## Output
Print the minimum possible total tiredness if the friends meet in the same point.
[samples]
## Note
In the first example the first friend should move by one to the right (then the meeting happens at point 4), or the second friend should move by one to the left (then the meeting happens at point 3). In both cases, the total tiredness becomes 1.
In the second example the first friend should move by one to the left, and the second friend should move by one to the right. Then they meet in the point 100, and the total tiredness becomes 1 + 1 = 2.
In the third example one of the optimal ways is the following. The first friend should move three times to the right, and the second friend — two times to the left. Thus the friends meet in the point 8, and the total tiredness becomes 1 + 2 + 3 + 1 + 2 = 9.
两位朋友位于坐标轴 #cf_span[Ox] 上,坐标为整数点。其中一位在点 #cf_span[x1 = a],另一位在点 #cf_span[x2 = b]。
每位朋友可以沿直线向任意方向移动任意次数,每次移动一单位距离。当朋友移动时,其疲劳值按以下规则变化:第一次移动增加 #cf_span[1] 点疲劳,第二次移动增加 #cf_span[2] 点疲劳,第三次增加 #cf_span[3] 点疲劳,依此类推。例如,如果一位朋友先向左移动,再向右移动(回到原点),然后再向左移动,他的疲劳值变为 #cf_span[1 + 2 + 3 = 6]。
两位朋友希望在某个整数点相遇。请确定他们相遇时所获得的最小总疲劳值。
第一行包含一个整数 #cf_span[a] (#cf_span[1 ≤ a ≤ 1000]) —— 第一位朋友的初始位置。
第二行包含一个整数 #cf_span[b] (#cf_span[1 ≤ b ≤ 1000]) —— 第二位朋友的初始位置。
保证 #cf_span[a ≠ b]。
请输出两位朋友在同一点相遇时可能的最小总疲劳值。
在第一个例子中,第一位朋友向右移动一单位(相遇点为 #cf_span[4]),或第二位朋友向左移动一单位(相遇点为 #cf_span[3])。两种情况下,总疲劳值均为 #cf_span[1]。
在第二个例子中,第一位朋友向左移动一单位,第二位朋友向右移动一单位。他们相遇在点 #cf_span[100],总疲劳值为 #cf_span[1 + 1 = 2]。
在第三个例子中,一种最优方案如下:第一位朋友向右移动三次,第二位朋友向左移动两次。于是他们在点 #cf_span[8] 相遇,总疲劳值为 #cf_span[1 + 2 + 3 + 1 + 2 = 9]。
## Input
第一行包含一个整数 #cf_span[a] (#cf_span[1 ≤ a ≤ 1000]) —— 第一位朋友的初始位置。第二行包含一个整数 #cf_span[b] (#cf_span[1 ≤ b ≤ 1000]) —— 第二位朋友的初始位置。保证 #cf_span[a ≠ b]。
## Output
请输出两位朋友在同一点相遇时可能的最小总疲劳值。
[samples]
## Note
在第一个例子中,第一位朋友向右移动一单位(相遇点为 #cf_span[4]),或第二位朋友向左移动一单位(相遇点为 #cf_span[3])。两种情况下,总疲劳值均为 #cf_span[1]。在第二个例子中,第一位朋友向左移动一单位,第二位朋友向右移动一单位。他们相遇在点 #cf_span[100],总疲劳值为 #cf_span[1 + 1 = 2]。在第三个例子中,一种最优方案如下:第一位朋友向右移动三次,第二位朋友向左移动两次。于是他们在点 #cf_span[8] 相遇,总疲劳值为 #cf_span[1 + 2 + 3 + 1 + 2 = 9]。
Let $ a, b \in \mathbb{Z} $, $ a \ne b $, be the initial positions of the two friends on the integer coordinate axis.
Let $ d = |a - b| $ be the initial distance between them.
Each friend can move any number of steps along the axis. The cost of the $ k $-th move for a friend is $ k $, so if a friend makes $ m $ moves, their total tiredness is $ T(m) = \frac{m(m+1)}{2} $.
The friends meet at some integer point $ p \in \mathbb{Z} $. Let $ m_1 = |p - a| $, $ m_2 = |p - b| $ be the number of moves made by the first and second friend, respectively.
The total tiredness is:
$$
T_{\text{total}} = \frac{m_1(m_1 + 1)}{2} + \frac{m_2(m_2 + 1)}{2}
$$
We seek to minimize $ T_{\text{total}} $ over all integers $ p \in \mathbb{Z} $.
Note: Since the cost function is convex and symmetric, the optimal meeting point lies between $ a $ and $ b $, and due to the discrete nature, we may restrict $ p \in [\min(a,b), \max(a,b)] $.
Let $ x = \min(a,b) $, $ y = \max(a,b) $, so $ d = y - x $.
For any integer $ p \in [x, y] $, define:
- $ m_1 = p - x $
- $ m_2 = y - p $
Then:
$$
T_{\text{total}}(p) = \frac{(p - x)(p - x + 1)}{2} + \frac{(y - p)(y - p + 1)}{2}
$$
We minimize $ T_{\text{total}}(p) $ over $ p \in \{x, x+1, \dots, y\} $.
Alternatively, since $ m_1 + m_2 = d $, let $ m_1 = k $, $ m_2 = d - k $, where $ k \in \{0, 1, \dots, d\} $.
Then:
$$
T_{\text{total}}(k) = \frac{k(k+1)}{2} + \frac{(d - k)(d - k + 1)}{2}
$$
Minimize $ T_{\text{total}}(k) $ for $ k \in \{0, 1, \dots, d\} $.
This is a quadratic in $ k $, and the minimum occurs at $ k \approx \frac{d}{2} $. Since $ k $ must be integer, check $ k = \left\lfloor \frac{d}{2} \right\rfloor $ and $ k = \left\lceil \frac{d}{2} \right\rceil $.
Thus, the minimal total tiredness is:
$$
\min_{k \in \{0,1,\dots,d\}} \left( \frac{k(k+1)}{2} + \frac{(d-k)(d-k+1)}{2} \right)
$$