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=input().split()
N=int(N)
L=int(L)
sum=N*L+(1+N)*N/2-N
if L+1-1<=0 and N+L-1>=0:
    print(int(sum))
elif L+1-1<=0 and N+L-1<=0:
    print(int(sum-(L+N-1)))
else:
    print(int(sum-(L+1-1)))

Solution (Python):
line1 = input().split()
line1 = list(map(int,line1))
ate = None
if line1[1] > 0:
    ate = line1[1]
elif line1[1] == 0:
    ate = 0
else:
    if abs(line1[1]) < line1[0]:
        ate = 0
    elif abs(line1[1]) >= line1[0]:
        ate = line1[0] + line1[1] - 1

print(sum(range(line1[1],line1[1]+line1[0])) - ate)

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


if l > 0:
    for i in range(n-1):
        ans += l + i + 1

elif l + n <= 0:
    for i in range(n-1):
        ans += l + i

else:
    for i in range(n):
        ans += l + i
        
print(ans)

Solution (Python):
hoge = input().split()
N = int(hoge[0])
L = int(hoge[1])

if L > 0:
  erase_apple = 0
elif L+N >= 0:
  for i in range(N+1):
    if i + L == 0:
      erase_apple = i
      break
else:
  erase_apple = N-1

if erase_apple == N:
  erase_apple = N-1

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

apples.pop(erase_apple)
print(sum(apples))

Solution (Python):
N, L = map(int, input().split())
list = [0]*N
list_abs = [0]*N
for i in range(N):
    list[i] = L+i
    list_abs[i] = abs(L+i)
index = sorted(range(N), key=lambda k: list_abs[k])
list.pop(index[0])
print(sum(list))

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

aji = [0] * N
aji2 = [0] * N
flag = 0

for i in range(N):
    aji[i] = L + (i+1) - 1
    aji2[i] = abs(aji[i])
    if aji[i] >= 0:
        flag = 1

if flag == 0:
    print(sum(aji) + min(aji2))
else:
    print(sum(aji) - min(aji2))

Solution (Python):
array = input().split(' ')

n = int(array[0])
ll = int(array[1])

sum_n = 0
have_zero = False
for i in range(n):
    sum_n += ll + i
    if sum_n == 0:
        have_zero = True

if have_zero:
    print(sum_n)
else:
    if ll >= 0:
        print(sum_n - ll)
    else:
        print(sum_n - (n + ll - 1))

Solution (Python):
import numpy as np

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

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

abs_aji = [abs(a) for a in aji]
index = np.argmin(abs_aji)
aji.pop(index)

print(sum(aji))

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

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


if 0 in aji:
  print(sum(aji))


elif sum(aji) > 0:
  print(sum(aji[1:]))
  
else:
  print(sum(aji[:-1]))

Solution (Python):

N,L = map(int,input().split())
lis =[]

for i in range(N):
    i += 1

    lis.append(L + i - 1)



mini = 0


for i in range(len(lis)):

    j = max(lis[i],-lis[i])
    k = max(lis[mini],-lis[mini])
        
    if i == 0 or k >= j:

        mini = i
    
        
        



ans = 0
for i in range(len(lis)):

    if i != mini:
        ans += lis[i]
   

print (ans)

Solution (Python):
import numpy as np

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

aji = []
for i in range(n):
    aji.append(L + i)

sa = 1000
for i in range(len(aji)):
    tmp = aji[i]
    if abs(tmp) <= abs(sa):
        sa = tmp
        idx = i

sum_ = np.sum(aji)
ans = sum_ - sa





print(ans)

Solution (Python):
n,l=list(map(int,input().split(" ")))
t=sum(range(l,l+n))
tmax=l+n-1
if l<0:
    if tmax>0:
        print(t)
    else:
        print(t-tmax)
else:
    print(t-l)

Solution (Python):
import os, sys, re, math

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

minv = 1000
for i in range(N):
    if abs(minv) > abs(L+i):
        minv = L+i

s = sum([L+i for i in range(N)])
print(s-minv)

Solution (Python):
import numpy as np
n, l = map(int, input().split())
r = np.arange(l, n + l)
print(r.sum() - r[np.abs(r).argmin()])

Solution (Python):
n, l = (int(x) for x in input().split())
a = [0]*n
for i in range(n):
    a[i] = l + i

b = [i ** 2 for i in a]
index = b.index(min(b))

print(int(n * l + n*(n+1)/2 - n - a[index]))

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

apples = []
minval = 200

for i in range(n):
    apples.append(i+l)

for i in apples:
    minval = min(minval, abs(i))

for i in apples:
    if minval == abs(i):
        print(sum(apples)-i)

Solution (Python):
n,l = list(map(int, input().split()))
import numpy as np
x = np.arange(l,l+n)
y = np.abs(x)
x = np.delete(x, np.argmin(y))
print(np.sum(x))

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

for i in range(n):
    true_sum += l+i

for j in range(n):
    tmp = 0
    for k in range(n):
        if k == j:
            continue
        else:
            tmp += l+k
    if abs(tmp - true_sum) < abs(false_sum - true_sum):
        false_sum = tmp

print(false_sum)

Solution (Python):
N, L = map(int, input().split())
import numpy as np
A=np.arange(L,L+N)
B=np.abs(A)

m=np.argmin(B)


r=sum(A)-int(A[m])
print(r)

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

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

def get_score(n):
    return L + n

score_total = 0

for i in range(N):
    score_ = get_score(i)
    score_total += score_

if L >= 0:
    score_min = score_total - L
elif (L < 0) and (L + N <= 0):
    
    score_min = score_total - get_score(N-1)
else:
    
    score_min = score_total
print(score_min)

Solution (Python):
N,L = map(int,input().split())
T = [L + n for n in range(N)]
del_taste = []
for i in range(N):
    del_taste.append(sum(T) - T[i])
diff = []
for i in range(N):
    diff.append(abs(sum(T)-del_taste[i]))
print(del_taste[diff.index(min(diff))])

Solution (Python):
n,l = map(int,input().split())
azi = 0
ls = []
for i in range(n):
    azi += l+i
    ls.append(abs(l + i))
if l + n-1 < 0:
    print(azi + min(ls))
else:
    print(azi - min(ls))

Solution (Python):
N,L = (int(i) for i in input().split())

taste=0

if L >= 0:
    for i in range(1,N):
        taste = taste + L + i

elif abs(L) < N:
    for i in range(N):
        taste = taste + L + i

else:
    for i in range(N-1):
        taste = taste + L + i
    
        
        
print(taste)

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

sum = (n * (n+1)) // 2 + (l-1) * n
if l > 0:
  sum -= l
elif l-1 + n < 0:
  sum -= l - 1 + n


print(sum)

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

true_pie = (2 * L + N - 1) * N // 2
min_diff = None
answer = None
for i in range(1, N + 1):
    apple = L + i - 1
    pie = (2 * L + N - 1) * N // 2 - apple
    diff = abs(true_pie - pie)
    
    if (min_diff is None) or (diff <= min_diff):
        min_diff = diff
        answer = pie

print(answer)

Solution (Python):
n,L=(int(i) for i in input().split())

mylist=[i+1 for i in range(n)]

maxval=0
for i in range(n):
  maxval+=L+mylist[i]-1
  


ans=float('inf')
for i in range(n):
  mylist=[i+1 for i in range(n)]
  tmp=0
  del mylist[i]
  for i in range(n-1):
    tmp+=L+mylist[i]-1
  tmp2=abs(maxval-tmp)
  if tmp2<ans:
    ans=tmp2
    ans2=tmp
    
print(ans2)

Solution (Python):
n,l=map(int,input().split())
a=0
b=300
c=300
for i in range(1,n+1):
    b=min(abs(b),abs(l+i-1))
    if c>b:
        c=b
        d=i
    a+=(l+i-1)
if l+d-1>=0:
    print(a-b)
else:
    print(a+b)

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

Solution (Python):
n,l = map(int, input().split())
dat = [];ans = []
for i in range(n):
  dat += [abs(l+i)]
  ans += [l+i]

i = dat.index(min(dat))

print(sum(ans[:i])+sum(ans[i+1:]))

Solution (Python):

import numpy as np
N, L= map(int, input().split())

n = np.arange(N) + L
ab = np.abs(n)
min_index = np.argmin(ab)

print(np.sum(n) - n[min_index])

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

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

m=min(s_list,key=abs)
ans=sum(s_list)-m
print(ans)

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

N = inp[0]
L = inp[1]

start = L
sum = 0
max_min = 99999999999
for i in range(N):
    x = start + i
    sum += x
    max_min = min(abs(x), max_min)

if sum < 0:
    sum += max_min
else:
    sum -= max_min

print(sum)

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

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

apple_pie = sum(Apples)

min_apple = 99999999999999
for i in range(len(Apples)):
    if min_apple > abs(Apples[i]):
        min_apple = abs(Apples[i])
        if Apples[i] > 0:
            flag = True
        else:
            flag = False

if flag:
    print(apple_pie - min_apple)
else:
    print(apple_pie + min_apple)

Solution (Python):

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

Taste = []
for i in range(N):
    Taste.append(L + i)

Taste.sort()

if 0 in Taste:
    ans = sum(Taste)
    print(ans)
    exit(0)


T_max = sum(Taste)
T_sum1 = sum(Taste[1:])
T_sum2 = sum(Taste[:-1])
if abs(T_max - T_sum1) < abs(T_max - T_sum2):
    ans = T_sum1
else:
    ans = T_sum2

print(ans)

Solution (Python):
a = list(map(int, input().split()))
aji=[]
m = 1000
for i in range(a[0]):
    aji.append(a[1]+i)
    if abs(m)>=abs(aji[i]):
        m=aji[i]
sum1 = sum(aji)
print(sum1-m)

Solution (Python):
a,b = map(int,input().split())

c=[]

for i in range(a):
    c.append(i+b)

d=sum(c)
dif=99999
f=99999
for j in c:
    e=d-j
    if abs(d-e)<dif:
        dif=abs(d-e)
        f=j
print(d-f)

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

res=sum(range(l,n+l))
if l<0:
    res-=min(0,l+n-1)
else:
    res-=l

print(res)

Solution (Python):
from sys import stdin
import numpy as np
N,L = [int(x) for x in stdin.readline().rstrip().split()]
aji = [0] * (N)
for i in range(N):
    aji[i] = i + L
min_aji = 100000
min_ = 0
for k in aji:
    if abs(k) < min_aji:
        min_aji = abs(k)
        min_ = k
ans = sum(aji) - min_
print(ans)

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

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

m = 1000
t = 1
for i in b:
    if m > abs(i):
        m = abs(i)
        if i<0:
            t = -1
        else:
            t = 1
print(sum(b)-m*t)

Solution (Python):
N,L=input().split()
A=[]
m=300
index=0
i=0
sum=0
for i in range(int(N)):
    A.append(int(L)+i)
    if abs(m)>abs(int(A[i])):
        m=int(A[i])
        index=i
for j in range(int(N)):
    if index==j:
        continue
    sum=sum+A[j]
print(sum)

Solution (Python):
n, l = map(int, input().split())
s=0
syou = l
for i in range(0,n):
    ss = l+i
    s+=ss
    if ss*ss < syou*syou:
        syou=ss
s-=syou
print(s)

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

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

alist = []
testlist = []
for i in range(n):
    if i == 0:
        alist.append(l)
        testlist.append(abs(l))
    else:
        alist.append(l+i)
        testlist.append(abs(l+i))
k = testlist.index(min(testlist))
alist.pop(k)
print(sum(alist))

Solution (Python):
N, L = map(int, input().split())
list_ = [L + i - 1 for i in range(1, N + 1)]
min_ = min(list_)
max_ = max(list_)
sum_ = sum(list_)

if min_ >= 0:
    print(sum_ - min_)
elif max_ <= 0:
    print(sum_ - max_)
else:
    print(sum_)

Solution (Python):
import numpy as np
N,L = map(int,input().split())
s = []
for i in range(N):
    s.append(L+i)
ans_pre = abs(np.array([s]))
if L + N <= 0:
    print(-1*(sum(ans_pre[0])-min(ans_pre[0])))
else:
    print(sum(s)-min(ans_pre[0]))

Solution (Python):
import math
n,l = map(int,input().split())
ans=0
min=9999
for i in range(n):
    ans+=l+i
    a=int(math.fabs(l+i))
    if int(math.fabs(min))>a:
        min=l+i
print(ans-min)

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

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

if L > -1:
    ans -= L
elif L <= -N:
    ans -= L + N - 1

print(ans)

Solution (Python):










temp=list(map(lambda x:int(x),input().split()))
N,L=temp[0],temp[1]

pie_aji_n=0

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

apples_aji=[]
for nuki in range(1,N+1):
    pie_aji_temp=0
    for i in range(1,N+1):
        if i==nuki:continue
        else:pie_aji_temp+=L+i-1
    apples_aji.append(pie_aji_temp)
best=1000000
for a in apples_aji:
    kyori=(pie_aji_n-a)**2
    if kyori<(pie_aji_n-best)**2:
        best=a

print(best)

Solution (Python):
def A(test=None):

    if test:
        pass
    else:
        S = input()

    continuous = 0
    for i in range(len(S)-1):
        if S[i] == S[i+1]:
            continuous += 1

    if continuous > 0:
        answer = 'Bad'
    else:
        answer = 'Good'

    print(answer)


def B(test=None):

    if test:
        N, L = test
    else:
        N, L = map(int, input().split())

    _sum = int(L * N - N + N * (N + 1) / 2)

    if L <= 0:
        ate = min(0, L + N - 1)
    else:
        ate = max(0, L)

    print(_sum - ate)

def main():
    
    B()


if __name__ == '__main__':
    main()

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

if L > -1:
    print((2*L+N)*(N-1)//2)
elif L+N<1:
    print((2*L+N-2)*(N-1)//2)
else:
    print((2*L+N-1)*N//2)

Solution (Python):
n,l=[int(_) for _ in input().split()]
t=[l+i-1 for i in range(1,n+1)]
if t[0] >= 0:
    print(sum(t[1:]))
elif t[-1] < 0:
    print(sum(t[:-1]))
else:
    print(sum(t))

Solution (Python):
N, L = map(int, input().split())
sum_n = 0
for i in range(N):
    sum_n += (L + i)
mini = 9999
for i in range(N):
    
    if abs(L + i) <= abs(mini):
        mini = (L + i)

print(sum_n - mini)

Solution (Python):
import sys,heapq
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True 
def ddprint(x):
  if DBG:
    print(x)

n,l = inm()
s = n*l+n*(n-1)//2
x = s
if l>0:
    x = s - l
elif l+n-1<0:
    x = s - (l+n-1)
print(x)

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

all = N * L + (N - 1) * N // 2
eat = float("inf")
for i in range(N):
  if abs(L + i) < abs(eat):
    eat = L + i
print(all - eat)

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

A.sort()

Ans=999
x=0
for n in range(N):
  if abs(A[n])<Ans:
    Ans=abs(A[n])
    x=A[n]

print(sum(A)-x)

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

if l >= 0:
    s = (n + 1) * n / 2 + (l - 1) * n - (l - 1) - 1
    print(int(s))
elif n + l > 0:
    s = (n + 1) * n / 2 + (l - 1) * n
    print(int(s))
else:
    s = (n + 1) * n / 2 + (l - 1) * n - (n + l - 1)
    print(int(s))

Solution (Python):


n, l = map(int, input().split())
o = [l+i-1 for i in range(1, n+1)]
oabs = [abs(l+i-1) for i in range(1, n+1)]


o.pop(oabs.index(min(oabs)))
print(sum(o))

Solution (Python):

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

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

ans = 100000000

for i in a:
    ans = min(ans, abs(i))

if ans in a:
    print(sum(a)-ans)
else:
    print(sum(a)+ans)

Solution (Python):
n, l = (int(_) for _ in input().split())
mi = 100000
ans = 0

for i in range(n):
    fla = l + i
    if abs(fla) < mi:
        minus = False
        mi = abs(fla)
        if abs(fla) != fla:
            minus = True
    ans += fla

if ans < 0:
    if minus:
        print(ans + mi)
    else:
        print(ans - mi)
else:
    print(ans - mi)

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

apples = []

m = abs(L)
ind = 0

for i in range(N):
    apples.append(L+i)
    if m > abs(L+i):
        m = abs(L+i)
        ind = i
        
apples.remove(apples[ind])

print(sum(apples))

Solution (Python):
from sys import stdin

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

taste=0
absMin=1000
min=1000
for i in range (L,L+N,1):
  if abs(i) < absMin:
    absMin=abs(i)
    min=i
  taste+=(i)
  
print(taste-min)

Solution (Python):
N, L = map(int, input().split())
sum = 0
flag0 = False
notallminus = False
for i in range(L, N+L):
    sum += i
    if i == 0:
        flag0 = True
    elif i > 0:
        notallminus = True
    else:
        pass

if flag0 is True and notallminus is True:
    print(sum)
elif flag0 is False and notallminus is True:
    print(sum - L)
else:
    print(sum - (N+L-1))

Solution (Python):
N, L = map(int, input().split())
if L > 0:
    a = range(L, L + N)
    print(sum(a) - L)
else:
    if L + N - 1 >= 0:
        a = range(L, L + N)
        print(sum(a))
    else:
        a = range(L, L + N)
        print(sum(a) - (L + N - 1))

Solution (Python):
n,l=map(int,input().split())
array=[l+i-1 for i in range(1,n+1)]
f = sum(array)
closest = -10 ** 100
for i in range(n):
    tmp = [t for t in array]
    del tmp[i]
    if abs(f - sum(tmp)) < abs(f - closest):
        closest = sum(tmp)
print (closest)

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

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

if all([i > 0 for i in T]):
    print(sum(T)-min(T))
elif any([i==0 for i in T]):
    print(sum(T))
else:
    print(sum(T)-max(T))

Solution (Python):
K,L = map(int,input().split())
apple = [i for i in range(L,L+K)]
apple.sort(key=lambda x:abs(x))
print(sum(apple[1:]))

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

aji = []
abs_min_aji = abs(l)
abs_min_aji_i = 0
for i in range(n):
    v = l + i+1 - 1
    aji.append(v)
    if abs_min_aji > abs(v):
        abs_min_aji = abs(v)
        abs_min_aji_i = i

print(sum(aji)-aji[abs_min_aji_i])

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

tmp = L+N-1
tmp_ind = 0
taste = []
for i in range(N):
  taste.append(L+int(i))

for j in range(N):
  if abs(taste[j]) < tmp:
    tmp = abs(taste[j])

print(sum(taste)-tmp)

Solution (Python):
n, l = map(int, input().split())
L = [i+l for i in range(n)]
mi = min(L)
if 0 in L:
  print(sum(L))
elif mi>0:
  print(sum(L)-min(list(map(abs,L))))
else:
  print(sum(L)+min(list(map(abs,L))))

Solution (Python):
N,L=map(int,input().split())
list_apple=[] 
eat_taste=300 
for i in range(N):
    taste=L+i-1+1
    list_apple.append(taste)
    
    if abs(eat_taste)>=abs(taste):
        eat_taste=taste
    
print("{}".format(sum(list_apple)-eat_taste))

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

list=[]
for i in range(N):
    list.append(L+i)
sum = sum(list)

if N>0 and L>0:
    print(sum-L)
elif 0 in list:
    print(sum)
else:
    print(sum-L-N+1)

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

taste = []

def checkio(numbers_array):
    return sorted(numbers_array, key=lambda x: abs(x))

for i in range(N):
    x=0
    x=(i+1)+L-1
    taste.append(x)

target = checkio(taste)
perfect = sum(taste)
ans = perfect - target[0]
print(ans)

Solution (Python):
N, L = map(int, input().split())
original_pi_taste = sum([L + i - 1 for i in range(1, N + 1)])
incomplete_pis_tastes = [original_pi_taste - (L + i - 1) for i in range(1, N + 1)]
taste_diffs = [abs(original_pi_taste - incomplete_pi_taste) for incomplete_pi_taste in incomplete_pis_tastes]
print(incomplete_pis_tastes[taste_diffs.index(min(taste_diffs))])

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

abs_tastes = []
tastes = []
for i in range(1, N + 1):
    taste = L + i - 1
    abs_tastes.append(abs(taste))
    tastes.append(taste)
min_taste = min(abs_tastes)
argmin = abs_tastes.index(min_taste)
sum_taste = sum(tastes)
print(sum_taste - tastes[argmin])

Solution (Python):
n,l=map(int,input().split())
y=l
k=[]
m=100000
for i in range(n):
    k.append(y)
    y+=1
for i in range(n):
    if abs(k[i])<abs(m):
        m=k[i]
k.pop(k.index(m))
print(sum(k))

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

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



for i in range(1,N+1):
    for j in range(1,N+1):
        if j == i:
            continue
        else:
            sum2 = sum2 + L + j - 1
    
    if abs(sum - sum2) < min:
        min = abs(sum-sum2)
        ans = sum2
    sum2 = 0

print(ans)

Solution (Python):

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

Solution (Python):
n,l = map(int, input().split())
tastes = [l+i for i,x in enumerate(range(n))]
eated = min([abs(i) for i in tastes]) if min([abs(i) for i in tastes]) >= 0 else -1*min([abs(i) for i in tastes])
if sum(tastes) >= 0:
    print(sum(tastes) - eated)
else:
    print(sum(tastes) + eated)

Solution (Python):
N,L = map(int,input().split())
ans = 0
e = 10**10
for i in range(1,N+1):
    tmp = L+i-1
    if abs(tmp) < abs(e):
        e = tmp
    ans += tmp
print(ans-e)

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


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


def B():
    n, l = LI()
    lis = [l + i for i in range(n)]
    s = sum(lis)
    a = inf
    for i in lis:
        if abs(a) > abs(i):
            a = i
    print(s-a)
    return


def C():
    def gcd(a, b):
        a, b = max(a, b), min(a, b)
        while b:
            a, b = b, a % b
        return a
    def lcm(a, b):
        return a * b // gcd(a, b)
    a, b, c, d = LI()
    x = b // c - (a-1) // c
    y = b // d - (a-1) // d
    z = b // lcm(c , d) - (a-1) // lcm(c , d)
    print(b-a+1-(x+y-z))
    return


def D():
    return


def E():
    return


def F():
    return


def G():
    return


def H():
    return


if __name__ == '__main__':
    B()

Solution (Python):
n,l=map(int,input().split())
tastes=[l+i for i in range(n)]
eaten=200
tmp=0
for i in range(n):
    if abs(tastes[i])<eaten:
        eaten=abs(tastes[i])
        tmp=i
print(sum(tastes)-tastes[tmp])

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

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

total = 0
list = []
ajilist = []
for i in range(N):
    aji = i + L
    total += aji
    list.append(abs(aji))
    ajilist.append(aji)

I = list.index(min(list))

ans = total - ajilist[I]

print(ans)

Solution (Python):
N, L = map(int, input().split())
aji = N*L + N*(N-1)//2
if L<=0:
  min_aji = min([0, L + N - 1])
  print(aji-min_aji)
else:
  print(aji - L)

Solution (Python):
N,L=[int(i) for i in input().split()]
min=L
max=N+L-1
eat=0
if min<=0 and max>=0:eat=0
elif max<0:eat=max
else:eat=min
print(L*N+(N-1)*(N)//2-eat)

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

l = [i for i in range(L, N+L)]
s = sum(l)
if L >= 0:
    print(s - l[0])
else:
    if l[-1] >= 0:
        print(s)
    else:
        print(s - l[-1])

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


if 0 in aji:
    ans=sum(aji)
else:
    if aji[0]>0:
        del aji[0]
    else:
        del aji[-1]
    ans=sum(aji)
print(ans)

Solution (Python):
N,J = map(int,input().split())
score = sorted([n+J for n in range(N)])
num = 100000000000
absscore = [abs(s) for s in score]
num = absscore.index(min(absscore))
print(sum(score)-score[num])

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


ans = [0]*N
INF = 10**9
myabs = INF
a_num = 0

for i in range(N):
    ans[i] = L+i
    if myabs > abs(ans[i]):
        myabs = abs(ans[i])
        a_num = i
    
out = 0
for i in range(N):
    if i == a_num:
        pass
    else:
        out += ans[i]

print(out)

Solution (Python):



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

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

if L >= 0:
    print("%d" % (apple_pie - L))

elif L <= 0 and (L + N - 1) >= 0:
    print("%d" % apple_pie)

else:
    print("%d" % (apple_pie - (L + N - 1)))

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



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



apple = []
for i in range(N):
    apple.append(L + i)


min = 1000
for i in range(N):
    if(min > abs(apple[i])):
        min = abs(apple[i])
        min_i = i

after_apple_pie = int(before_apple_pie - apple[min_i])

print(after_apple_pie)

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

aji = []
for i in range(n):
    a = l + i
    aji.append(a)

s = sum(aji)
ans = 0
dif = []
for i in range(n):
    sd = s - aji[i]
    b = abs(s-sd)
    dif.append(b)
    
ans = s - aji[dif.index(min(dif))]

print(ans)

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

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

ajiabs = [abs(i) for i in (range(L,L+N))]
ajiabssort = sorted(ajiabs)
min_idx = ajiabs.index(ajiabssort[0])

aji = [i for i in (range(L,L+N))]
aji.pop(min_idx)

print(sum(aji))

Solution (Python):
n,l=map(int,input().split())
a=n*(n+1)/2+(l-1)*n
a=int(a)

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

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

Solution (Python):
import numpy as np
N, L = map(int,input().split())
array = np.arange(L, L+N)
abs_array=abs(array)
ate=abs_array.argmin()
array=np.delete(array, ate)
answer=sum(array)

print(answer)

Solution (Python):
nl = input().split()
n = int(nl[0])
l = int(nl[1])

a = [l+i for i in range(n)]
b = [abs(a[i]) for i in range(n)]
b.sort()
c = b[0]
cnt = 0
t = 0
for i in range(n):
  if abs(a[i]) != c :
    t += a[i]
  elif abs(a[i]) == c and cnt == 0:
    cnt += 1
print(t)

Solution (Python):
line = list(map(int, input().split(" ")))
N = line[0]
L = line[1]
sum = 0
for i in range(N):
	sum = sum + L+i

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

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

Solution (Python):
N, L = map(int, input().split())
T = []
tmp = [abs(L+i-1) for i in range(1, N+1)]
mini = min(tmp)

for i in range(N):
    taste = L+i
    if mini == abs(taste):
        continue
    T.append(taste)

print(sum(T))

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

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

if L >= 0:
    print( sum(list(range(L+1, L+N))) )
elif N + L > 0:
    print( sum(list(range(L, L+N))) )
else:
    print( sum(list(range(L, L+N-1))) )

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

taste = [L+i-1 for i in range(1,N+1)]
n_applepie = sum(taste)

for i in range(len(taste)):
    taste[i] = n_applepie - taste[i]

ans_index = 0
for i in range(len(taste)):
    if abs(taste[i]-n_applepie) < abs(taste[ans_index]-n_applepie):
        ans_index = i

print(taste[ans_index])

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

ans = 0
zettaichi = 101
ttt = 0

for i in range(N):
    t = i + L
    ans += i + L
    if zettaichi > abs(t):
        zettaichi = abs(t)
        ttt = t
print(ans - ttt)

Solution (Python):
N ,L= map(int,input().split())
one_aji = 0
aji = []
answer = []
for i in range(N):
    one_aji = L+i
    if one_aji < 0:
        answer.append(one_aji)
        one_aji *= -1
        aji.append(one_aji)
    else:
        aji.append(one_aji)
        answer.append(one_aji)
zettai = 500
ind = 0
for i, a in enumerate(aji):
    a = int(a)
    if a < zettai:
        zettai = a
        ind = i
         
answer.pop(ind)
print(sum(answer))

Solution (Python):

import sys
import bisect 

def solve(N: int, L: int):
    li = [i for i in range(L,L+N)]

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

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    L = int(next(tokens))  
    solve(N, L)

if __name__ == '__main__':
    main()

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

v=[]
for i in range(n):
    v.append(l+i)
if min(v)>=0:
    del v[0]
elif min(v)<0 and max(v)>=0:
    v.remove(0)
else:
    del v[-1]
print(sum(v))

Solution (Python):
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]






N, L = map(int, input().split())
a = [0]*( N+1)

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

tmp = sum(a)

cnt = int(1e18)
ans = int(1e18)

for i in range(1, N+1):
    now = tmp - (tmp - a[i])
    if abs(now) < cnt:
        cnt = abs(now)
        ans = tmp - a[i]
print(ans)

Solution (Python):
N, L = map(int,input().split())
List = [L + i for i in range(N) ]
abs = [abs(num) for num in List]
index = abs.index(min(abs))
Answer = sum(List) -List[index]

print(Answer)

Solution (Python):
N,L = input().split()
N = int(N)
L = int(L)
sum = (2*L+N-1)*N//2
if L>=0:
  print(sum-L)
elif L+N-1 >0:
  print(sum)
else:
  print(sum-L-N+1)