#ABC131B. Bite Eating

Bite Eating

题目描述

You have NN apples, called Apple 11, Apple 22, Apple 33, ..., Apple NN. The flavor of Apple ii is L+i1L+i-1, which can be negative.

You can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.

You planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.

You want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N1N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the NN apples.

Find the flavor of the apple pie made of the remaining N1N-1 apples when you choose the apple to eat as above.

We can prove that this value is uniquely determined.

你有 NN 个苹果,分别叫做苹果 11 ,苹果 22 ,苹果 33 ......,苹果 NN 。苹果 ii 的_味道_是 L+i1L+i-1 ,可以是负数。

您可以用一个或多个苹果制作苹果派。苹果派的味道将是所用苹果味道的总和。

你计划用所有的苹果制作一个苹果派,但饥饿的诱惑让你吃掉了其中一个,这 个苹果就不能再用来制作苹果派了。

你想做一个与你计划做的苹果派尽可能相似的苹果派。因此,你要选择吃掉的苹果,使剩下的 N1N-1 个苹果做成的苹果派的味道与所有 NN 个苹果做成的苹果派的味道的绝对差异尽可能小。

求用剩下的 N1N-1 个苹果做成的苹果派的味道。

我们可以证明这个值是唯一确定的。

输入格式

输入内容按以下格式标准输入:

NN LL

输出格式

找出用剩余的 N1N-1 个苹果做成的苹果派的味道,并优化选择吃的苹果。

样例 #1

样例输入 #1

5 2

样例输出 #1

18

样例 #2

样例输入 #2

3 -1

样例输出 #2

0

样例 #3

样例输入 #3

30 -50

样例输出 #3

-1044

说明

数据规模与约定

  • 2N2002 \leq N \leq 200
  • 100L100-100 \leq L \leq 100
  • 所有输入值均为整数。

样例 11 解释

苹果 1122334455 的味道分别是 2233445566 。最佳选择是吃苹果 11 ,所以答案是 3+4+5+6=183+4+5+6=18

样例 22 解释

苹果 112233 的味道分别是 1-10011 。最佳选择是吃苹果 22 ,所以答案是 (1)+1=0(-1)+1=0