Problem:
 Score : 200 points    Problem Statement You have N apples, called Apple 1 , Apple 2 , Apple 3 , ..., Apple N . The flavor of Apple i is L+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 N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.  Find the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.  We can prove that this value is uniquely determined.      Constraints  2 \leq N \leq 200  -100 \leq L \leq 100  All values in input are integers.         Input Input is given from Standard Input in the following format:  N  L       Output Find the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.        Sample Input 1 5 2      Sample Output 1 18  The flavors of Apple 1 , 2 , 3 , 4 , and 5 are 2 , 3 , 4 , 5 , and 6 , respectively. The optimal choice is to eat Apple 1 , so the answer is 3+4+5+6=18 .       Sample Input 2 3 -1      Sample Output 2 0  The flavors of Apple 1 , 2 , and 3 are -1 , 0 , and 1 , respectively. The optimal choice is to eat Apple 2 , so the answer is (-1)+1=0 .       Sample Input 3 30 -50      Sample Output 3 -1044

Solution (Python):
N, L = map(int, input().split())
A = []
s = 0
for i in range(N):
    A.append(L + i)
    s += L + i

mi = float('inf')
t = 0
for i in range(N):
    tmp = 0
    for j in range(N):
        if i != j:
            tmp += A[j]

    if abs(tmp - s) < mi:
        mi = abs(tmp - s)
        t = tmp


print(t)

Solution (Python):

from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

import random
import collections
import math
import itertools
import bisect

def real_main():
    n, l = read_int_array()
    min_i = min(range(n), key=lambda x: abs(x + l))
    print(sum(x + l for x in range(n)) - (min_i + l))


def solve():
    pass


def main():
    if False and 'PYCHARM_HOSTED' in os.environ:
        main_pycharm()
    else:
        real_main()


from copy import deepcopy
def main_pycharm():
    solution = solve

    test_inputs = None
    test_outputs = None
    judge = None
    slow_solution = None
    if solution is not None:
        if test_outputs is not None:
            test_with_answers(solution, test_inputs, test_outputs)
        if judge is not None:
            test_with_judge(solution, test_inputs, judge)
        if slow_solution is not None:
            test_with_slow_solution(solution, test_inputs, slow_solution)


def test_with_answers(solution, inputs, answers):
    total, wrong = 0, 0
    for args, test_ans in zip(inputs, answers):
        ans = solution(*deepcopy(args))
        if ans != test_ans:
            print('WRONG! ans=%s, test_ans=%s, args=%s' % (ans, test_ans, args))
            wrong += 1
        else:
            print('GOOD')
        total += 1
    print('ALL %d TESTS PASSED' % total if not wrong else '%d out of %d tests are WRONG' % (wrong, total))


def test_with_judge(solution, inputs_gen, judge):
    total, wrong = 0, 0
    for args in inputs_gen:
        ans = solution(*deepcopy(args))
        if not judge(deepcopy(ans), *deepcopy(args)):
            print('WRONG! ans=%s, args=%s' % (ans, args))
            wrong += 1
        total += 1
    print('ALL %d TESTS PASSED' % total if not wrong else '%d out of %d tests are WRONG' % (wrong, total))


def test_with_slow_solution(solution, inputs_gen, solution_slow):
    total, wrong = 0, 0
    for args in inputs_gen:
        ans = solution(*deepcopy(args))
        slow = solution_slow(*deepcopy(args))
        if ans != slow:
            print('WRONG! ans=%s, slow=%s, args=%s' % (ans, slow, args))
            wrong += 1
        total += 1
    print('ALL %d TESTS PASSED' % total if not wrong else '%d out of %d tests are WRONG' % (wrong, total))




def mergesort(A, key=lambda x: x, reverse=False):
    C = A
    A = list(range(len(A)))
    B = list(A)

    n = len(A)
    for i in range(0, n - 1, 2):
        if key(C[A[i]]) > key(C[A[i ^ 1]]):
            A[i], A[i ^ 1] = A[i ^ 1], A[i]

    width = 2
    while width < n:
        for i in range(0, n, 2 * width):
            R1, R2 = min(i + width, n), min(i + 2 * width, n)
            j, k = R1, i
            while i < R1 and j < R2:
                if key(C[A[i]]) > key(C[A[j]]):
                    B[k] = A[j]
                    j += 1
                else:
                    B[k] = A[i]
                    i += 1
                k += 1
            while i < R1:
                B[k] = A[i]
                k += 1
                i += 1
            while k < R2:
                B[k] = A[k]
                k += 1
        A, B = B, A
        width *= 2

    if reverse:
        A.reverse()
    return A




BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

def read():
    return input()

def read_int():
    return int(input())

def read_array(sep=None, maxsplit=-1):
    return input().split(sep, maxsplit)

def read_int_array():
    return [int(a) for a in read_array()]



if __name__ == "__main__":
    main()

Solution (Python):
from collections import deque
from itertools import accumulate
import sys
sys.setrecursionlimit(10**6)
mo=10**9+7


n,l=map(int,input().split())

a=[l+i-1 for i in range(1,n+1)]
if 0 in a:
    ans=sum(a)
elif l>0:
    ans=sum(a)-l
else:
    ans=sum(a)-(l+n-1)
    
print(ans)

Solution (Python):
n,l = map(int,input().split())

ll = []
p = []
for i in range(n):
    ll.append(l + i)
    p.append(abs(l + i))

res = -1
tmp = 10 ** 100
sm = sum(ll)

for i in ll:
    dif = abs(sm - (sm - i))
    if dif < tmp:
        tmp = dif
        res = sm - i
    

print(res)

Solution (Python):
from bisect import bisect_left, bisect_right; from collections import Counter, defaultdict, deque, OrderedDict; from copy import deepcopy; from fractions import gcd; from functools import lru_cache, reduce; from math import ceil, floor; from sys import stdin, setrecursionlimit
import heapq as hq; import itertools as its; import operator as op



inf = float('inf')
input = stdin.readline


def main():
    n, l = get_li()
    tastes = list(range(l, l+n))
    print(sum(tastes) - min(tastes, key=lambda x: abs(x)))
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    setrecursionlimit(4100000)
    main()

Solution (Python):
n, l = map(int, input().split())
a = [l + i for i in range(n)]
a.sort(key=lambda x:abs(x))
print(sum(a) - a[0])

Solution (Python):
N, L = map(int, input().split())

S = 0
r_abs = 1000
r = 1000

for i in range(N):
    S += i + L
    if abs(i + L) < r_abs:
        r_abs = abs(i + L)
        r = i + L

print(S - r)

Solution (Python):
N, L = map(int,input().split())
A = [L+i for i in range(N)]
ans = sum(A)
mini = 10**10
ap = None
for a in A:
    if abs(a) < mini:
        ap = a
        mini = abs(a)
print(ans - ap)

Solution (Python):




n,l = [int(i) for i in input().split()]

ans = sum([l+i for i in range(n)])

if l>=0:
    print(ans - l)
elif l+n-1 <= 0:
    print(ans-(l+n-1))
else:
    print(ans)

Solution (Python):











import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N, L = MI()
    A = [L + i for i in range(N)]
    if A[0] * A[-1] < 0:
        print(sum(A))
    else:
        if A[0] >= 0:
            print(sum(A) - A[0])
        else:
            print(sum(A)-A[-1])
if __name__ == '__main__':
    main()

Solution (Python):
n,l=map(int,input().split())
arr=[0]*n
for i in range(n):
  arr[i]=l+i+1-1
s=sum(arr)
ans=0
diff=10**10
for i in range(n):
  tmp=arr[:i]+arr[i+1:]
  tmps=sum(tmp)
  if diff>abs(s-tmps):
    ans=tmps
    diff=abs(s-tmps)
print(ans)

Solution (Python):
n, l = map(int, input().split())
a = float("inf")
b = 0
s = 0
for i in range(n):
    s += l+i
    if a > abs(l+i):
        b = i
        a = abs(l+i)
print(s - (l+b))

Solution (Python):
n,l=list(map(int,input().split()))
arr=[]
for i in range(1,n+1):
	arr.append(l+i-1)
sumx=sum(arr)
diff=10000000000000
ans=0
for i in range(n):
	temp=sumx-arr[i]
	if(abs(sumx-temp)<=diff):
		diff=abs(sumx-temp)
		ans=temp

print(ans)

Solution (Python):
n,l = map(int, input().split())

a = float('inf')
b = 0

for i in range(n):
    b+=l+i
    if abs(l+i)<abs(a):
        a = l+i

print(b-a)

Solution (Python):
N,L = map(int,input().split())
A = [L+i for i in range(N)]
x = 10**9
y = -1
for a in A:
    if abs(a) < x:
        x = abs(a)
        y = a
print(sum(A) - y)

Solution (Python):
n, like = map(int, input().split())

arr = [like + i for i in range(n)]

arr.sort(key=lambda x:abs(x))

print(sum(arr[1:]))

Solution (Python):
N,L = map(int,input().split())
taste = [L+i for i in range(N)]
abstaste = sorted(taste,key = abs)
print(sum(taste)-abstaste[0])

Solution (Python):

def main():
    buf = input()
    buflist = buf.split()
    N = int(buflist[0])
    L = int(buflist[1])
    apple = []
    for i in range(N):
        apple.append(L+i)
    nearest = int(1e9)+7
    for i in range(N):
        if abs(apple[i]) < abs(nearest):
            nearest = apple[i]
    print(sum(apple) - nearest)

if __name__ == '__main__':
    main()

Solution (Python):
N, L = map(int, input().split())
A = [L+i for i in range(N)]
mi = 99999
for i in range(N):
    if abs(mi) > abs(A[i]):
        mi = A[i]
print(sum(A)-mi)

Solution (Python):
N, L = map(int, input().split())
s = sum(L + i - 1 for i in range(1, N + 1))
ans = sum(L + i - 1 for i in range(2, N + 1))
for i in range(1, N + 1):
    s1 = s - (L + i - 1)
    if abs(s - ans) > abs(s - s1):
        ans = s1
print(ans)

Solution (Python):
N,L = list(map(int,input().split()))

A = [[abs(L+i),i] for i in range(N)]

A.sort(lambda x:x[0])

j=A[0][1]
s=0
for i in range(N):
    if i!=j:
        s+=L+i

print(s)

Solution (Python):
N, L = map(int, input().split())

apple = [L + i for i in range(N)]
eat = 10 ** 10
for a in apple:
    if abs(a) < abs(eat):
        eat = a
print(sum(apple) - eat)

Solution (Python):
n, l = [int(i) for i in input().split()]

S = 0
mi = int(1e19)

for i in range(n):
    a = l + i
    if abs(a) < abs(mi):
        mi = a
    S += a

print(S - mi)

Solution (Python):
n, l = map(int, input().split())

ans = 0
t = 1000000
for i in range(1, n + 1):
    p = l + i - 1
    ans += p;
    if abs(p) < abs(t):
        t = p
print(ans - t)

Solution (Python):
N, L = list(map(int, input().split()))

m = 300
s = 0
for i in range(N):
    if abs(L + i) < abs(m):
        m = L + i
    s += L + i

print(s - m)

Solution (Python):
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from fractions import gcd
from functools import lru_cache, reduce

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")








N, L = list(map(int, sys.stdin.readline().split()))

a = np.arange(L, L + N)
d = abs(a).argmin()
print(a.sum() - a[d])

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def YesNo(x): return 'Yes' if x else 'No'
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N, L = LI()
    li = list(range(L, N + L))
    if 0 in li:
        ans = sum(li)
    elif li[-1] < 0:
        ans = sum(li[:-1])
    else:
        ans = sum(li[1:])
    return ans

print(main())

Solution (Python):
import sys
input = sys.stdin.readline
ri = lambda: int(input())


rl = lambda: map(int,input().split())
rr = lambda N: [list(l) for l in zip(*[rl() for _ in range(N)])]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD = 10**9+7

N,L=rl()
azi = [L+i-1 for i in range(1,N+1)]
S = sum(azi)
ind = 0
M = INF
for i in range(N):
    a = azi[i]
    if abs(a) < M:
        M = abs(a)
        ind = i

print(S-azi[ind])

Solution (Python):
N, L = map(int, input().split())
A = []
mi = float("inf")
for i in range(N):
    A.append(L+i)
    if abs(mi) > abs(L+i):
        mi = L+i
ans = sum(A) - mi
print(ans)

Solution (Python):

n, l = map(int,input().split())
A = []
for i in range(n):
    A.append(l+i)

ind = -1
minr = 10**10
for i in range(n):
    if abs(A[i])<minr:
        minr = abs(A[i])
        ind = i
print(sum(A)-A[ind])

Solution (Python):
N, L = map(int, input().split())

apples= []
for i in range(1,N + 1):
    apples.append(L + i - 1)

As =sorted(apples,key=lambda x: abs(x))

print(sum(As) - As[0])

Solution (Python):
N, L = map(int, input().split())
A = [L+i-1 for i in range(1, N+1)]
S = sum(A)
diff = float('inf')
ans = 0
for i in range(N):
    x = S - A[i]
    d = abs(S - x)
    if d < diff:
        diff = d
        ans = x
print(ans)

Solution (Python):
import math
import fractions
import copy
import numpy as np
def j(q):
    if q==1: print("Bad")
    elif q == 0:print("Good")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def printrow(a):
    for i in a:
        print(i)
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


n,l= (int(i) for i in input().split())       








a = [l+i for i in range(n)]
if min(a)>=0:
    a.pop(0)
elif max(a) < 0:
    a.pop(-1)
print(sum(a))

Solution (Python):
import sys
input = sys.stdin.readline

N,L=map(int,input().split())
A=[L+i for i in range(N)]
A.sort(key=lambda x:abs(x))

print(sum(A[1:]))

Solution (Python):


from collections import deque
import itertools as ite
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N, L = map(int, raw_input().split())
if L <= 0 < L + N:
    print sum(i for i in range(L, L + N))
elif 0 < L:
    print sum(i for i in range(L + 1, L + N))
else:
    print sum(i for i in range(L, L + N - 1))

Solution (Python):
n, l = list(map(int, input().split()))
a = [0 for i in range(n)]
for i in range(n):
  a[i] = l+i
a.sort(key=lambda x:abs(x))
print(sum(a[1:]))

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007


def A():
    s = S()
    for i in range(len(s)-1):
        if s[i] == s[i+1]:
            print("Bad")
            quit()
    print("Good")
    return


def B():
    n,l = LI()
    a = [i+l for i in range(n)]
    ans = sum(a)
    m = n+l-1
    for i in a[::-1]:
        if i < 0:break
        m = min(m,i)
    ans -= m
    print(ans)
    return


def C():
    n = I()

    return


def D():
    n = I()

    return


def E():
    n = I()

    return


def F():
    n = I()

    return


if __name__ == "__main__":
    B()

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  

n, l = na()

r = l+n-1

if l >= 0:
    s = 0
    for i in range(l+1, r+1):
        s += i
    print(s)
elif r <= 0:
    s = 0
    for i in range(l, r):
        s += i
    print(s)
else:
    s = 0
    for i in range(l, r+1):
        s += i
    print(s)