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-----
5 2

-----Sample Output-----
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.

Difficulty: introductory

Starter code:

Solutions:
n,l=map(int,input().split())
c=0
m=100000
for i in range(1,n+1):
  c+=l+i-1
  m=min(m,abs(l+i-1))
if l<0 and l-n<=0:
  print(c+m)
else:
  print(c-m)

n,l=map(int,input().split())
sum=0
m=1e9
for i in range (n):
    sum+=l+i
    if abs(m)>abs(l+i):m=l+i
print(sum-m)

import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return list(map(int, input().split()))
def MI1(): return list(map(int1, input().split()))
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print((k.join(list(map(str, lst)))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque, defaultdict
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N, L = MI()
    tot = 0
    for i in range(1, N+1):
        tot = tot + L + i - 1
    diff = INF
    ans = 0
    for i in range(1, N+1):
        tmp = tot - L - i + 1
        if abs(tot - tmp) < diff:
            diff = abs(tot - tmp)
            ans = tmp
    print(ans)

def __starting_point():
    solve()


__starting_point()

# import math
# import statistics
# import itertools
# a=int(input())
#b,c=int(input()),int(input())
# c=[]
# for i in a:
#     c.append(int(i))
N,L= list(map(int,input().split()))
# f = list(map(int,input().split()))
# g = [input().split for _ in range(a)]
# h = []
# for i in range(a):
#     h.append(list(map(int,input().split())))
# a = [[0] for _ in range(H)]#nizigen

azi2=[]
azi=[L+i for i in range(N)]
for i in azi:
    azi2.append(abs(i))
if 0 in azi:
    print((sum(azi)))
else:
    mi=azi2.index(min(azi2))
    del azi[mi]
    print((sum(azi)))
    


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

apple = []
for i in range(1, n+1):
    apple.append(l+i-1)

eat = sorted(apple, key=lambda x: abs(x))
print(sum(apple)-eat[0])

N,L=map(int,input().split())
sum_apple=0
if L<0 and L+N-1<0:
  for i in range(1,N):
    sum_apple+=L+i-1
elif L>0 and L+N-1>0:
  for i in range(2,N+1):
    sum_apple+=L+i-1
else:
  for i in range(1,N+1):
    sum_apple+=L+i-1
print(sum_apple)

N, L = map(int, input().split())
chosen = 1000
for i in range(1, N+1):
  taste_eaten = L + i - 1
  if abs(taste_eaten) < abs(chosen):
    chosen = taste_eaten
print(int(N*L + N*(N+1)/2 - N - chosen))

N,L = map(int,input().split())

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

ans = float("inf")
res = float("inf")

for apple in apples:
  if ans > abs(apple):
    ans = min(ans,abs(apple))
    res = apple
  
print(sum(apples) - res)

N,L = map(int,input().split())
ans = 0
for i in range(1,N+1):
    if L-1>=0 and i==1:
        continue
    if L-1<0 and L+N-1>=0 and i==1-L:
        continue
    if L-1<0 and L+N-1<0 and i==N:
        continue
    ans += L+i-1

print(ans)

n, l =list(map(int, input().split()))
arr = []
arr2 = []
for k in range(1, n+1):
  arr.append(abs(l + k - 1))
for k in range(1, n+1):
  arr2.append(l + k - 1)
arr2.pop(arr.index(min(arr)))
print(sum(arr2))

# N,Lを取得する
N, L = map(int, input().split())
# 味のリストを作成する
tastes = []
for i in range(1,N+1):
    tastes.append(L+i-1)
    
# 味の絶対値が最も小さいリストのindexを取得する
abs_tastes = list(map(abs, tastes))
min_tastes_index = abs_tastes.index(min(abs_tastes))
tastes.pop(min_tastes_index)

# 上記リンゴを除いた残りのリンゴの味の総和を求める
print(sum(tastes))

N, L = map(int, input().split())

total = N * (L - 1) + N * (N + 1) / 2
lowest = 10 ** 10
for i in range(1, N + 1):
    y = L + i - 1
    lowest = min(lowest, abs(y))
print(int(total) - lowest) if total >= 0 else print(int(total) + lowest)

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


n, l = map(int, input().split())
L = []
a = 0
if 0 <= l:
  a = l
else:
  a = n - 1 + l
for i in range(n):
  if (l + i) == 0:
    a = 0
  L.append(l + i)
L.remove(a)
print(sum(L))

n,l=list(map(int,input().split()))
aji = []
m = 100000
flg = 0
for i in range(n):
  aji.append((l+i))
  if abs(aji[i]) <= m:
    m = abs(aji[i])
    if aji[i] <= 0:
      flg = 1
    else:
      flg = 0
print((sum(aji)- m if flg==0 else sum(aji) +m))


N, L = map(int, input().split())
ans = 0
mn = 300000
for i in range(1, N + 1):
    x = L + i - 1
    ans += x
    if abs(x) < abs(mn):
        mn = x
print(ans - mn)

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

apples = []
ans = 300
for i in range(1, n + 1):
    taste = i + l - 1
    apples.append(taste)
    if abs(taste) < abs(ans):
        ans = taste

apples.remove(ans)
print((sum(apples)))


n, l = list(map(int, input().split()))
S = n*l + (n * (n + 1)) // 2 - n
pd = S + 1
for x in range(1, n + 1):
    d = - l - x + 1
    if pd > abs(d):
        ans = S + d
    pd = d

print(ans)


def answer(n: int, l: int) -> int:
    apples_taste = list(range(l, l + n))
    applepie_taste = sum(apples_taste) - min(apples_taste, key=abs)

    return applepie_taste


def main():
    n, l = list(map(int, input().split()))
    print((answer(n, l)))


def __starting_point():
    main()

__starting_point()

N,L=map(int, input().split())
azi=[L+i-1 for i in range(1,N+1)]

absmin=L**2

for i in range(N):
	absmin=min(absmin,abs(azi[i]))

if absmin in azi:
	print(sum(azi)-absmin)
else:
	print(sum(azi)+absmin)

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

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

if T[-1] >= 0:
    m = min((i for i in T if i >= 0))
else:
    m = T[-1]

print(sum(T)-m)

n,l=map(int,input().split())
s = sum(range(l,l+n))
ans = 1000
for i in range(l,l+n):
  if abs(i) <= abs(ans):
    ans = i
print(s-ans)

N,M = map(int,input().split())
if M >= 0:
    a_list = [i for i in range(M+1,M+N)]
elif N + M > 0:
    a_list = [i for i in range(M,M+N)]
else:
    a_list = [i for i in range(M,M+N-1)]
print(sum(a_list))

n, l = map(int, input().split())
a = [l+i for i in range(n)]
if 0 in a:
    print(sum(a))
elif a[0] < 0:
    print(sum(a)-a[-1])
else:
    print(sum(a)-a[0])

N,L = list(map(int,input().split()))
flavor = []
flavorabs = []
for i in range(1,N+1):
    flavor.append(L+i-1)
S = 0

for i in flavor:
    S += i

for i in range(N):
    flavorabs.append(abs(flavor[i]))

a = min(flavorabs)
print((S - flavor[flavorabs.index(a)]))


N,L=map(int,input().split())
s = N*L
for i in range (N+1):
    s += i
s -= N
K=[]
for i in range(1,N+1):  
    K.append(L+i-1)
if 0 <= K[0]:
    s -= K[0]
elif K[0]<0 and K[N-1]>0:
    s = s
else:
    s -= K[N-1]
print(s)

n, l = list(map(int, input().split()))
apple_list = [l + i for i in range(n)]
abs_min = min([abs(apple) for apple in apple_list])
apple_list.remove(abs_min if abs_min in apple_list else -abs_min)
print((sum(apple_list)))


n, l = map(int,input().split())
List1 = []
List2 = []

for i in range(n):
    L = l + i
    L_abs = abs(L)
    List1.append(L)
    List2.append(L_abs)

if min(List2) in List1:
    List1.remove(min(List2))
elif -min(List2) in List1:
    List1.remove(-min(List2))

print(sum(List1))

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

l_list=[l+i-1 for i in range(1,n+1)]
#print(l_list)

ab_list=[abs(i) for i in l_list]
num=ab_list.index(min(ab_list))

print(sum(l_list)-l_list[num])

a,b=input().split()
a=int(a)
b=int(b)
c=a*(b+b+a-1)/2
if b>0:
  print(int(c-b))
else:
  if b+a-1>0:
    print(int(c))
  else:
    print(int(c-(b+a-1)))

n,l = map(int,input().split())
ans = 0
mv = 100000
for i in range(1,n+1):
  tmp = l+i-1
  ans += tmp
  if abs(mv)>abs(tmp):
    mv = tmp
print(ans-mv)

import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, L = LI()

    ans = (2 * L + N - 1) * N // 2
    if 0 <= L:
        ans -= L
    elif L + N <= 0:
        ans -= L + N - 1

    print(ans)

def __starting_point():
    resolve()

__starting_point()

apple_num, taste = map(int, input().split())
total = 0
table = []
total_ans = 0
manual = 100000000
ans = 0
for i in range(apple_num):
    table.append(i+1)

for j in range(apple_num):
    table[j] = taste + j
    total += taste + j

for k in range(apple_num):
    if manual > abs(table[k]):
        manual = abs(table[k])
        ans = k
for l in range(apple_num):
    if l == ans:
        continue
    else:
        total_ans += table[l]
print(total_ans)

n, l = list(map(int, input().split()))
azi = [l+i-1 for i in range(1, n+1)]
diff = [0]*n
for i in range(n):
    diff[i] = abs(azi[i])

if sum(azi) < 0:
    print((sum(azi) + abs(min(diff))))
else:  
    print((sum(azi) - min(diff)))



N, L = map(int, input().split())
A = []
for i in range(N):
  A.append(L+i)
i = 0
ans = False
while ans == False:
    x, y = abs(i), -abs(i)
    for k in A:
      if k == x or k == y:
        ans = True
        A.remove(k)
    i += 1
print(sum(A))

N, L = map(int, input().split())
 
s = N*(2*L+N-1) // 2
l = [abs(L+i) for i in range(N)]

print(s - (L+l.index(min(l))))

N,L=map(int,input().split())
s=0
l=[]
for i in range(N):
    s+=L+i
    l.append(abs(L+i))
l=sorted(l)
if l[0]<=L:
    s-=l[0]
else:
    s+=l[0]
print(s)

N, L = map(int, input().split())

s = (L * 2 + N - 1) * N // 2

if L >= 0:
    print(s - L)
elif L + N - 1 <= 0:
    print(s - L - N + 1)
else:
    print(s)

import numpy as np

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

taste = np.arange(1, N+1) + L -1
min_ind = np.argmin(np.abs(taste))

mask_1 = np.ones(N, dtype=bool)
mask_1[min_ind] = False

ans = np.sum(taste[mask_1])

print(ans)


# 入力を受け取る
N,L = map(int, input().split())

# 数列を作成する
nums = list(range(1,N+1))
tasts = [L+num-1 for num in nums]

# 味の絶対値が最も小さいリンゴのindexを特定する
abs_tasts = list(map(abs,tasts))
index = abs_tasts.index(min(abs_tasts))
tasts.pop(index)

# 上記リンゴを除いた残りのリンゴの味の総和を求める
print(sum(tasts))

n,l=map(int,input().split())
l1=list(int(l)+i-1 for i in range(1,n+1))
n1=sum(l1)
ans=min(l1,key=abs)

print(n1-(ans))

n,a = map(int,input().split())
c = 0
d = 1000
for i in range(1,n+1):
    c+=a+i-1
    d = min(abs(a+i-1),d)
if a<0 and a-n <= 0:
    print(c+d)
else:
    print(c-d)

n,l = map(int,input().split())
ans = l 
k = 0
sum = 0
for i in range(1,n):
    if abs(ans) > abs(l + i):
        ans = l + i
        k = i
for i in range(n):
    if i != k:
        sum += l + i
print(sum)

lst = input()
lst = lst.split()


for i in range(len(lst)):
    lst[i]= int(lst[i])
N = lst[0]
L = lst[1]
q = L
l = 0
lste = [abs(L)]
tlst = []
for i in range(2,N+1):
    t = L+i-1
    q += t
    tlst.append(t)
    t = abs(t)
    lste.append(t)


slst = sorted(lste)
l = slst[0]
if tlst.count(-l) > 0:
    print(q+l)
else:
    print(q-l)

n,l=map(int,input().split())
apple=[l+i for i in range(n)]
s=0
while True:
    if s in apple:
        apple.remove(s)
        break
    elif abs(s) in apple:
        apple.remove(abs(s))
        break
    s-=1
print(sum(apple))

n, l = map(int, input().split())
a = []
for i in range(l, n + l):
    a.append(i)
if a[0] > 0:
    b = a.pop(0)
elif a[n - 1] < 0:
    b = a.pop(n - 1)
else:
    for j in range(n):
        if a[j] == 0:
            b = a.pop(j)
            break
print(sum(a))

N, L = map(int, input().split())
S = (2*L+N-1)*N // 2
if L <= 0 <= L+N-1:
  ans = S
elif L < 0:
  ans = S - (L+N-1)
else:
  ans = S - L
print(ans)

n, l = map(int, input().split())
t = []
t2 = []
for i in range(n):
    taste = l+(i+1)-1
    t.append(taste)
    t2.append(taste**2)
oa = t[t2.index(min(t2))]
ans = sum(t) - oa
print(ans)

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


#ABC131 B

N,L = map(int,input().split())
aji = []
for i in range(N):
    aji.append(L+i)
if L < 0 and L+N-1 > 0:
    print(sum(aji))
elif L+N-1 <= 0:
    print(sum(aji) - (L+N-1))
elif L >= 0:
    print(sum(aji) - L)

n,l = map(int,input().split())
q = []
p = []
ans = 0
for i in range(1,n+1):
  m = l+i-1
  q.append(m)
  ans += m
for i in range(n):
    p.append(abs(q[i]))

print(ans - q[p.index(min(p))])

N,L = map(int,input().split())
A = []
for i in range(N):
  A.append(i+L)
  
if L < 0 and A.count(0) > 0:
  print(sum(A))
elif L < 0:
  print(sum(A[:-1]))
else:
  print(sum(A[1:]))

N, L = map(int, input().split())
# 味：L + i - 1
aji_list = [L+i-1 for i in range(1, N+1)]

basic = abs(sum(aji_list))
min_diff = 9999999 
for i in aji_list:
    diff = abs(basic - abs(basic - abs(i)))
    min_diff = min(min_diff, diff)

for i in aji_list:
    if abs(basic - abs(basic - abs(i))) == min_diff:
        if basic == sum(aji_list):
            print(basic - abs(i))
        else:
            print(-1*(basic - abs(i)))
        break

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

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

if(min(lt) > 0):
    print(sum(lt[1:]))
elif(max(lt) < 0):
    print(sum(lt[:n-1]))
else:
    print(sum(lt))

def mapt(fn, *args):
    return tuple(map(fn, *args))


def Input():
    return mapt(int, input().split(" "))


def sum_applepie(list1, l):
    r = [i+l-1 for i in list1]
    return sum(r)


def main():
    n, l = Input()
    applepie = sum_applepie(list(range(1, n+1)), l)
    list2 = []
    for i in range(1, n+1):
        temp = []
        for j in range(1, n+1):
            if i == j:continue
            temp.append(j)
        k = sum_applepie(temp, l)
        list2.append((abs(applepie - k), k))
    print(sorted(list2, key=lambda x:x[0])[0][1])


main()

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

apple = []
diff = 1001001001
minus = False
for i in range(1, n+1):
    apple.append(l+i-1)
    if abs(l+i-1) < diff:
        diff = abs(l+i-1)
        if l+i-1 < 0:
            minus = True
        else:
            minus = False

if minus:
    print(sum(apple) + diff)
else:
    print(sum(apple) - diff)

r=input().split()
N=int(r[0])
L=int(r[1])
ans=0
ans_li=[]
for i in range(N):
    ans+=L+(i+1)-1
    ans_li.append(L+(i+1)-1)
if 0 in ans_li:
    print(ans)
elif max(ans_li)>0:
    print(ans-min(ans_li))
else:
    print(ans-max(ans_li))

N, L = map(int, input().split())

T = [L+i for i in range(N)]

if T[-1] >= 0:
    m = min((i for i in T if i >= 0))
else:
    m = T[-1]

print(sum(T)-m)

n, l = list(map(int, input().split()))
if l >= 0:
    print(((n - 1) * l + (n * (n + 1)) // 2 - (n - 1) - 1))
else:
    if n >= -l + 1:
        print((n * l + (n * (n + 1)) // 2 - n))
    else:
        print(((n - 1) * l + (n * (n + 1)) // 2 - (n - 1) - n))


N,L=list(map(int,input().split()))
#L+i-1,i>=1
nin=10**6
for i in range(N):
    if abs(L+i)<nin:
        nin=abs(L+i)
        nn=L+i

ans=N*(L-1)+N*(N+1)*0.5-(nn)

print((int(ans)))


n, l = map(int, input().split())
a = 0
if l >= 0:
    a = (l+1+n + l -1)*(n-1)/2
    print(int(a))

elif l < 0 and -l < n:
    a = (l+n + l -1)*n/2
    print(int(a))
elif l < 0 and -l >=n:
    a = (l+ n + l -2)*(n-1)/2
    print(int(a))

import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n, l = MI()
    ans = 0
    temp = l
    for i in range(n):
        ans += l+i
        if abs(temp) > abs(l+i):
            temp = l+i
        
    ans -= temp
    print(ans)

def __starting_point():
    main()
__starting_point()

#nはりんごの数　りんごiの味はl＋i-1

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

each_taste = []
for x in range(1,n+1):
  each_taste.append(l+x-1)
  
if min(each_taste) >= 0:
  print(sum(each_taste[1:]))
  
elif max(each_taste) >= 0:
  print(sum(each_taste))

else:
  print(sum(each_taste[:-1]))

import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readlines
def main():
    lines = input()

    n, l = list(map(int, lines[0].split()))

    Sum_ = int( n * (l - 1) + n * (n+1) / 2 )

    if l >= 0:
        print(Sum_ - l)
        return
    else:
        if n+l-1 <= 0:
            print(Sum_ - (l+n-1))
        else:
            print(Sum_)


main()

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

ans = 0
for i in range(1, N+1):
    ans += L+i-1
    

if L+N-1 < 0:
    ans -= (L+N-1)
elif L <= 0 <= L+N-1:
    ans = ans
else:
    ans -= L
print(ans)


N, L = map(int, input().split())
 
# 元々の味（等差数列の和の公式より）
s = N*(2*L+N-1) // 2
# 味の絶対値が最小になるリンゴの味を求める
if L+N-1 < 0: eat = L+N-1
elif L > 0: eat = L
else: eat = 0

# 食べる（最適なリンゴ）以外の味の和
print(s - eat)

n, l = list(map(int, input().split()))
s = n*(l-1) + n*(n+1)/2
c = abs(s)
j = 1
for i in range(n):
  t = s - (l+i)
  T = abs(s-t)
  if T < c:
    c = T
    j = i
ans = s -(l+j)
print((int(ans)))



# N, Lを取得する
N, L = map(int, input().split())

# 味の総和を求める
La = N * L + (N-1) * N / 2

# Le=（リンゴiを取り除いた時の味の総和）とLa=（全リンゴの味の総和）の絶対値が最小となる時のLeを求める
min_Le = La
abs_L = int(1e100)
for i in range(N):
    Li = L + (i + 1) - 1
    if abs((La - Li) - La) < abs_L:
        Le = La - Li
        abs_L = abs(Le - La)

# 結果出力
print(int(Le))

n,l = map(int,input().split())
m = list(range(l,l+n))
if m[-1] < 0:
    print(sum(m[:n-1]))
elif m[0] > 0:
    print(sum(m[1:]))
else:
    print(sum(m))

n, l = list(map(int, input().split()))
apples = []
min_val = l

for i in range(1, n + 1):
    apples.append(l + i - 1)
    if abs(l + i - 1) < abs(min_val):
        min_val = (l + i - 1)
apples.remove(min_val)

print((sum(apples)))


details = input().split()
N = int(details[0])
L = int(details[1])
counter = 0
new_list = []
number = 0
checker = True
for i in range(N):
    counter += L
    new_list.append(L+i)
    if number == 0 and ((L + i) >= 0) and checker == True:
        number += L + i
        checker = False
    elif number == 0 and (i == N-1) and checker == True:
        number += L + i
        checker = False
print(sum(new_list) - number)

n,l =map(int,input().split())
if l+n-1 <0:
    print((n-1)*(l-1)+n*(n-1)//2)
elif l > 0:
    print(n*(l-1)+n*(n+1)//2-l)
else:
    print(n*(l-1)+n*(n+1)//2)

n,a = map(int,input().split())
x = [a+i-1+1 for i in range(n)]
y = sorted(x, key=lambda i: abs(i))
del y[0]
print(sum(y))

N,L = map(int,input().split())
aji1 = []
ajimin = 1000

for i in range(1,N+1):
    aji1.append(L + i - 1)
    if abs(ajimin) >= abs(aji1[i-1]):
        ajimin = aji1[i-1]


print(sum(aji1)-ajimin)

n, l = map(int, input().split())
m = 1000
for i in range(l, l+n):
    if abs(i) < m:
        m = abs(i)
        a = i
print(sum(range(l, l+n)) - a)

n, l = list(map(int, input().split()))
a = sorted([l + i for i in range(n)], key=abs)
print((sum(a[1:])))



n,l = map(int,input().split())
s = int(n*(2*l+n-1)/2)
if(l<=0 and l+n-1 >=0):
  print(s)
elif(l<=0):
  print(s-l-n+1)
else:
  print(s-l)

N, L = map(int, input().split(" "))

apple = [L+i-1 for i in range(1, N+1)]

abs_apple = list(map(abs, apple))

minimum_idx = abs_apple.index(min(abs_apple))

print(sum(apple) - apple[minimum_idx])

n, l = map(int,input().split())
lst = []
for i in range(n):
  lst.append(l + i)
if (0 in lst):
  print(sum(lst))
elif (l < 0):
  print(sum(lst) - lst[n - 1])
else:
  print(sum(lst) - lst[0])

n,l = map(int,input().split())
ans = 0
if l > 0:
    for i in range(l+1,l+n):
        ans += i
elif n + l -1 < 0:
    for i in range(l,l+n-1):
        ans += i
else:
    for i in range(l,l+n):
        ans += i
print(ans)

n,l=map(int,input().split())
a=0
for i in range(1,n+1):
  a+=(l+i-1)

m=10**9
idx=1
for i in range(1,n+1):
  if abs(l+i-1)<m:
    m=abs(l+i-1)
    idx=i
        
print(a-(l+idx-1))

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

ringo = []
for i in range(l,l+n):
    ringo.append(i)
ringo.sort(key=int)
if 0 in ringo:
    print(sum(ringo))
else:
    if ringo[0] > 0:
        ringo.pop(0)
    else:
        ringo.pop(-1)
    print(sum(ringo))

N, L = list(map(int, input().split()))
stk = []
ans = []
for i in range(N):
  tmp = L + i
  stk.append(tmp)

for i in range(N):
  tmp1 = sum(stk)
  tmp = stk[i]
  stk[i] = 0
  tmp2 = sum(stk)
  stk[i] = tmp
  ans.append(abs(tmp1 - tmp2))

tmp = min(ans)

if tmp in stk:
  stk.remove(tmp)
  print(sum(stk))
else:
  stk.remove(-tmp)
  print(sum(stk))

n,l = map(int,input().split())
isMina = False
isPlu = False
ans = []
for i in range(1,n+1):
  ans.append(l+i-1)
  if l+i-1 < 0:
    isMina = True
  elif i+i-1 > 0:
    isPlu = True
print(sum(ans)-min(ans) if not isMina else sum(ans)-max(ans) if not isPlu else sum(ans))

n,l=map(int, input().split())
s=int(n*(l+n+l-1)/2)
if l>0 and n+l-1>0:
  print(s-l)
elif l<0 and n+l-1<0:
  print(s-(n+l-1))
else:
  print(s)

# AtCoder Beginner Contest 131
# B - Bite Eating

N,L=map(int,input().split())
minabs=10**9
apples=[]
for i in range (N):
    t=L+i
    apples.append(t)
    if abs(t)<abs(minabs):
        minabs=t

full=sum(apples)

print(full-minabs)

def ApplePie():
    N, L = input().split()
    N = int(N)
    L = int(L)
    flavors = []
    for i in range(N):
        flavors.append(L+i)
    
    if 0 in flavors:
        flavors.remove(0)
        result = 0
        for i in flavors:
            result = result + i
        print(result)
        return
    elif L >= 0:
        del flavors[0]
        result = 0
        for i in flavors:
            result = result + i
        print(result)
        return
    else:
        del flavors[-1]
        result = 0
        for i in flavors:
            result = result + i
        print(result)
        return
        
ApplePie()


lst = list(map(int, input().split()))

N = lst[0]
L = lst[1]

apple_flavours = []

for i in range(1, N+1):
    apple_flavours.append(L+i-1)


abs_apple_flavours = []

for apple in apple_flavours:
    abs_apple_flavours.append(abs(apple))

min_val = min(abs_apple_flavours)

index = abs_apple_flavours.index(min_val)

total_flavour = 0

for apple in apple_flavours:
    total_flavour += apple

print(total_flavour - apple_flavours[index])

import sys
N, L = list(map(int, input().split()))
tastes = [ L+x for x in range(N) ] 

if 0 in tastes:
    print((sum(tastes)))
    return
    

if L<0:
    absmin = max(tastes)
    print((sum(tastes)-absmin))
elif L>0:
    absmin = min(tastes)
    print((sum(tastes)-absmin))



# ABC131
# B Bite Eating
N, L = list(map(int, input().split()))
A = 0
a = 1000
for i in range(1,N+1):
    x = L + i - 1
    A += x
    if abs(x) < a:
        a = abs(x)
if A >= 0:
    print((A-a))
else:
    print((A+a))


N, L = list(map(int,input().split()))
A = []
for i in range(N):
    x = L + i
    A.append(x)

y = sum(A)
B = sorted(A)

if L <= 0 and L + N - 1 >= 0:
    print(y)
elif L >= 0:
    y -= B[0]
    print(y)
elif L + N - 1 < 0:
    y -= B[N - 1]
    print(y) 



N, L = map(int, input().split())

# 元々の味（等差数列の和の公式より）
s = N*(2*L+N-1) // 2
# 味の差の絶対値=リンゴiの味の絶対値
l = [abs(L+i) for i in range(N)]
 
# 味の絶対値が最小になるリンゴのindexを求め、sからその味を引けばよい
print(s - (L+l.index(min(l))))

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

aji = [l+i for i in range(n)]
ans = None
sa=10**10
for i in range(n):
    sa_tmp=abs(aji[i])
    if sa>sa_tmp:
        sa=sa_tmp
        ans=sum(aji)-aji[i]
print(ans)


N,L = map(int,input().split())
a = []
for i in range(1,N+1):
  a.append(L+i-1)
b = []
for i in a:
  b.append(abs(i))
for i in range(1,N+1):
  if abs(L+i-1) == min(b):
    print(sum(a)-L-i+1)

n,l = map(int,input().split())
li = []
ind = 0
for i in range(1,n+1):
    li.append(i+l-1)

mi = abs(li[0])
for i in li:
    if abs(i) < mi:
        mi = abs(i)
        ind = li.index(i)

print(sum(li)-li[ind])

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

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

if A[0] < 0:
    if A[-1] < 0:
        print((sum(A) - max(A)))
    else:
        print((sum(A)))
else:
    print((sum(A) - min(A)))


n,l=map(int,input().split())
list_x=[l+x-1 for x in range(1,n+1)]
applepai=sum(list_x)
list_dif=[]
list_sum=[]
for i in range(len(list_x)):
    tmp=list_x.pop(i)
    list_dif.append(abs(applepai-sum(list_x)))
    list_sum.append(sum(list_x))
    list_x.insert(i,tmp)
indx=list_dif.index(min(list_dif))
ans=list_sum[indx]
print(ans)

n, l = (int(i) for i in input().split())
list_ringo = [l + i - 1 for i in range(1, n + 1)]
if 0 in list_ringo: print(sum(list_ringo))
elif max(list_ringo) < 0: print(sum(list_ringo[:n - 1]))
else: print(sum(list_ringo[1:]))

import sys

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

taste_list = [l+x-1 for x in range(1,n+1)]
taste_sum = sum(taste_list)
diff = sys.maxsize

for i in range(n):
    if diff>abs(taste_list[i]):
        diff = abs(taste_list[i])
        num = i
    
print(taste_sum-taste_list[num])