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())

list_t = list(range(l, l+n))



index = 0

comp = abs(list_t[0])
for n, i in enumerate(list_t):
    if comp > abs(i):
        comp = abs(i)
        index = n

print(sum(list_t[:index] + list_t[index+1:]))

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

Solution (Python):
n,l=list(map(int, input().split()))
a=[l+i for i in range(n)]
b=[abs(a[i]) for i in range(n)]
j=b.index(min(b))
print(sum(a)-a[j])

Solution (Python):
n,l=list(map(int, input().split()))
a=[l+i for i in range(n)]
b=[abs(a[i]) for i in range(n)]
j=b.index(min(b))
sum=0
for i in range(n):
	sum+=a[i]
print(sum-a[j])

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

apples = [i + l - 1 for i in range(1, n+1)]
all = sum(apples)
diff = 500
ans = 0

for i in range(n):
  point = sum(apples[i+1:] + apples[:-n+i])
  nextDiff= abs(point-all)
  if min(nextDiff, diff) == nextDiff:
    diff = nextDiff
    ans = point

print(ans)

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

lis = list(map(abs,li))
li.pop(lis.index(min(lis)))
print(sum(li))

Solution (Python):
N,L=map(int, input().split())
taste = [0]*N
for i in range(N):
    taste[i] = L+i
zenbu = sum(taste)

dif = 10**9
for i in taste:
    if abs(zenbu - (zenbu-i)) < dif:
        dif = abs(zenbu - (zenbu-i))
        ans = zenbu-i

print(ans)

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

start, end = l, n+l - 1
if start*end < 0:
	print(sum(i for i in range(start, end+1)))
elif start < 0:
	print(sum(i for i in range(start, end)))
else:
	print(sum(i for i in range(start+1, end+1)))

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

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

Solution (Python):
n,l = map(int,input().split())
abs_lis = [abs(i) for i in range(l,n+l)]
i = abs_lis.index(min(abs_lis))
ans = sum(range(l,n+l))-range(l,n+l)[i]
print(ans)

Solution (Python):
n, l = map(int, input().split())
dic = []
all_sum = sum([j + l -1 for j in range(1, n+1)])
for i in range(1, n+1):
  item = [j + l -1 for j in range(1, n+1) if j != i]
  dic.append(sum(item))
dist = abs(all_sum - dic[0])
ans = dic[0]
for j in dic:
  tmp = abs(all_sum - j)
  if tmp < dist:
    ans = j
    dist = tmp
print(ans)

Solution (Python):
n,l = map(int, input().split())
ap = list(l+i-1 for i in range(1,n+1))

if ap[0]<0 and ap[n-1]<=0:
    print(sum(ap)-ap[n-1])
if ap[0]>=0 and ap[n-1]>0:
    print(sum(ap)-ap[0])
if ap[0]<0 and ap[n-1]>0:
    print(sum(ap))

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

sum_taste = 0
min_abs = 999
idx = -1
for i in range(n):
    taste = l+i
    if min_abs > abs(taste):
        min_abs = abs(taste)
        idx = i
    sum_taste += taste

print(sum_taste - (l+idx))

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

end = start + n - 1
sumall = (start + end ) * n // 2

ans = -(10**10)
for i in range(n):
	exclude = start + i
	if abs(exclude) < abs(ans - sumall):
		ans = sumall - exclude

print(ans)

Solution (Python):
N,L =list(map(int, input().split()))
n = list(range(1,N+1))
tasteA = list(map(lambda x: x + L -1, n))
tasteB = list(map(lambda x: abs(x), tasteA))
tasteC = sum(tasteA) - min(tasteB)
tasteD = sum(tasteA) + min(tasteB)
if abs(tasteC) < abs(tasteD):
    print(tasteC)
else:
    print(tasteD)

Solution (Python):
import numpy as np


N, L = map(int, input().split())
tasty_list = np.array([L+i-1 for i in range(1, N+1)])
eat_apple_idx = np.argmin(np.abs(tasty_list))
print(np.sum(tasty_list) - tasty_list[eat_apple_idx])

Solution (Python):
N,L=map(int,input().split())
a=[]
sum=0

for i in range(1,N+1):
    taste=L+i-1
    a.append(taste)
    sum +=taste

b=min(a,key=abs)
ans=sum-b
print(ans)

Solution (Python):
n, l = map(int,input().split())
min = 10**5
ans = 0
for i in range(1, n + 1):
    tmp = n*(l-1) + n*(n+1)//2 - (l+i-1)
    if abs(l+i-1) < min:
        ans = tmp
        min = abs(l+i-1)
print(ans)

Solution (Python):
n,k = map(int,input().split())
l =list(range(k,k+n))
l2 = []
for i in range(0,n):
    l2.append(abs(l[i]))
print(sum(l)-l[l2.index(min(l2))])

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

for i in range(2, n+1):
    pi = l + i - 1
    if abs(pi) < abs(min):
        min = pi
    ans += pi
print(ans-min)

Solution (Python):
import copy
import sys
from _operator import itemgetter
from collections import Counter
from math import log2, pi, ceil

stdin = sys.stdin

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

n, l = na()
m = n * (n + 1) // 2 + (l - 1) * n
li = []
for i in list(range(l + 1 - 1, l + n)):
    li.append((abs(i), i))
print(m - sorted(li, key=itemgetter(0))[0][1])

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

eaten = lst[0]

for e in lst:
    if abs(e) < abs(eaten):
        eaten = e

ans = 0-eaten
for e in lst:
    ans += e


print(ans)

Solution (Python):
N,L=map(int,input().split())
if 0<=L:
  count1=0
  for i in range(L+1,L+N):
    count1+=i
  print(count1)
elif L+N-1<=0:
  count2=0
  for j in range(L,L+N-1):
    count2+=j
  print(count2)
else:
  count3=0
  for k in range (L,L+N):
    count3+=k
  print(count3)

Solution (Python):


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

Solution (Python):
N,l=map(int,input().split())
apples=[]
apples_abs=[]
for n in range(1,N+1):
    apples.append(l+n-1)
    apples_abs.append(abs(l+n-1))
print(sum(apples)-apples[apples_abs.index(min(apples_abs))])

Solution (Python):
n, l = list(map(int, input().split()))
apple = 0
apples = []
eat = None
for i in range(1,n+1):
    apples.append(l+i-1)
    apple = l+i-1
    if i==1:
        eat = apple
    else:
        if abs(eat) > abs(apple):
            eat = apple
print(sum(apples) - eat)

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

minabs=200
mini=200
sum=0
for i in range(L,L+n):
  if minabs!=min(minabs,abs(i)):
    mini=i
    minabs=abs(i)
  sum=sum+i

sum=sum-mini
print(sum)

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

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

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

Solution (Python):
N,L=map(int,input().split())
T=[]
for i in range(N):
    T.append(L+(i+1)-1)    
output=0
if min(T)>0:
    for j in T:
        output=output+j
    output=output-min(T)
elif max(T)<0:
    for j in T:
        output=output+j
    output=output-max(T)
else:
    for j in T:
        output=output+j
print(output)

Solution (Python):
n, l = list(map(int, input().split(' ')))
n_cake = n * l + n * (n + 1) // 2 - n
now_min = 10**10
ans = n_cake - l

for i in range(1, n + 1):
    minus_cake = n_cake - (l + i - 1)
    if abs(n_cake - minus_cake) < now_min:
        ans = minus_cake
        now_min = abs(n_cake - minus_cake)

print(ans)

Solution (Python):
def taste(L, i):
    return L + i -1

def main(): 

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

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

    min_diff = 201

    sum = 0
    for i in range(1, N+1):
        sum_tmp = 0
        for j in range(1, N+1):
            if i == j:
                continue
            else:
                sum_tmp += taste(L, j)
        if min_diff > abs(sum_all - sum_tmp):
            min_diff = abs(sum_all - sum_tmp)
            sum = sum_tmp

    print(sum)

if __name__ == "__main__":
    main()

Solution (Python):

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

count = 0
eat = l
for i in range(l, l+n):
    count += i
    if abs(eat) > abs(i):
        eat = i

print(count - eat)

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

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

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

if 0 in aji:
    print(pie)
elif min(aji) < 0:
    print(sum(aji[:n-1]))
else:
    print(sum(aji[1:]))

Solution (Python):
n,l = map(int,input().split())
all = n*(l-1) + n*(n+1)//2
values = []
for i in range(n):
    if l+i < 0:
        values.append([abs(l+i),0])
    else:
        values.append([abs(l+i),1])
values.sort()
if values[0][1] == 1:
    print(all-values[0][0])
else:
    print(all+values[0][0])

Solution (Python):
n,l=input().split(" ")
N=int(n)
L=int(l)
def sum(l,n):
    a=0
    for i in range (l,n+1):
        a+=i
    return a
def x(N,L):
    a=abs(L)
    b=1
    for i in range (1, N+1):
        if a>abs(L+i-1):
            b=i
            a=abs(L+i-1)
    return sum(L,L+N-1)-(L+b-1)
print (int(x(N,L)))

Solution (Python):
from sys import stdin

n, l = [int(v) for v in stdin.readline().rstrip().split()]

a_lst = [l+i for i in range(n)]
a_p_lst = [abs(l+i) for i in range(n)]

p = a_p_lst.index(min(a_p_lst))
print(sum(a_lst)-a_lst[p])

Solution (Python):
n,l=map(int,input().split())
ans=l*n+(-1)*n
for i in range(1,n+1):
	ans+=i
aji=float('inf')
for i in range(1,n+1):
	if aji>abs(l+i-1):
		aji=abs(l+i-1)
		sin=l+i-1
print(ans-sin)

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

Solution (Python):
N,L = map(int,input().split())
azi = []
for i in range(N):
    azi.append(i+L)
if min(azi) > 0:
    k = min(azi)
elif min(azi) <= 0 and max(azi) >= 0:
    k = 0
elif max(azi) < 0:
    k = max(azi)
azi.remove(k)
print(sum(azi))

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

Solution (Python):
N,L = map(int,input().split())
aji = [L+i for i in range(N)]
ate = 10000
for a in aji:
  if abs(ate) > abs(a):
    ate = a
print(sum(aji)-ate)

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

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

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

Solution (Python):
N,L=map(int,input().split())
sum=(L-1)*N+(N+1)*N//2
mi=1000
for i in range(1,N+1):
    temp=L+i-1
    if abs(temp)<mi:
        idx=i
        mi=abs(temp)

print(sum-L-idx+1)

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

if L<=0:
    print(sum-(L+min(-L+1,N)-1))
else:
    print(sum-L)

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

Apple.sort(key=lambda x:abs(x))
print(sum(Apple[1:]))

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

Solution (Python):
N, L = map(int, input().split())
lst = [L + i for i in range(N)]
sumlst = sum(lst)
mindiff = 500
index = 0
for j in range(N):
    if mindiff > abs(lst[j]):
        mindiff = abs(lst[j])
        index = j
print(sumlst - lst[index])

Solution (Python):
n, l = map(int, input().split())
s = [int(l+i-1) for i in range(1,n+1)]
a = [(int(l+i-1))**2 for i in range(1,n+1)]
b = a.index(min(a))
s[b] = 0
print(sum(s))

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

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

eaten = 101
for i in l:
    if abs(i) < abs(eaten):
        eaten = i
    

print((l[0] + l[N-1])*N //2 - eaten)

Solution (Python):
import numpy as np

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

aji_sum = 1 / 2 * N * (N + 2*L - 1)
aji_arr = np.ones(N) * L
aji_arr += np.arange(N)

eat_a = aji_arr[np.argmin(np.abs(aji_arr))]
    
print(int(aji_sum - eat_a))

Solution (Python):
while True:
    try:
        N, L = map(int, input().split())
        flavor = [i+L-1 for i in range(1, N+1)]
        mini = 2**31-1
        eaten = -1
        for i in range(N):
            tmp = abs(flavor[i])
            if tmp < mini:
                mini = tmp
                eaten = i
        print(sum(flavor) - flavor[eaten])
    except:
        break

Solution (Python):
N,L = list(map(int,input().split()))
A = list(range(L,L+N))
ans = sum(A)
mi = min(list(map(abs,A)))
if abs(A[0])==mi:
  print(ans-A[0])
elif abs(A[N-1])==mi:
  print(ans-A[N-1])
else:
  print(ans-mi)

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

if l <= 0:
  if -1 * l >= n:
    n -= 1
else:
  l += 1
  n -= 1

print(int(n*(2*l+n-1)/2))

Solution (Python):
N, L = map(int,input().split())
Aji =[0]*N
for i in range(N):
    Aji[i] = L +i
AjiAbs = list(map(abs,Aji))
minAjiAbs = min(AjiAbs)
a=AjiAbs.index(minAjiAbs)

print(sum(Aji)-Aji[a])

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

taste=[l+i-1 for i in range(1,n+1)]
best=sum(taste)
ans=100000
for i in range(n):
  ans=min(ans,abs(taste[i]))
if best>=0:
  print(best-ans)
else:
  print(-(abs(best)-ans))

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

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


taberu_abs = float('inf')
for a in apple:
    if abs(a) < taberu_abs:
        taberu_abs = abs(a)
        taberu = a

print(sum(apple) - taberu)

Solution (Python):
N,L = map(int,input().split())
min = 99999
for x in range(N):
    t = L+x
    tmp = abs(t)
    if tmp < abs(min):
        min = t
sum = (2*L+N-1)*N//2
print(sum-min)

Solution (Python):
n,l = map(int, input().split())
a = []
ans = 0
for i in range(1, n+1):
  a.append([l + i - 1, abs(l + i - 1)])
a = sorted(a, key = lambda x:x[1], reverse = True)
a.pop()
for i in range(n-1):
  ans += a[i][0]
print(ans)

Solution (Python):
n,L=map(int,input().split())
taste = list([L+i-1 for i in range(1,n+1)])
taste_before = sum(taste)
l=min(taste)
r=max(taste)
if r<=0:
    taste_after = taste_before - r
elif l<0<r:
    taste_after = taste_before
else:
    taste_after = taste_before - l
print(int(taste_after))

Solution (Python):
n,l = map(int,input().split())
num_min = abs(l)
for i in range(l,l+n):
    if  abs(i)<abs(num_min):
        num_min = i
print(sum(range(l,l+n))-num_min)

Solution (Python):

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

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

lst = list(range(L,N+L))
sumlst = sum(lst)

if lst.count(0) == 1:
    print(sumlst)
else:
    
    if ( L > 0 ):
        print( sumlst - min(lst) )
    else:
        print( sumlst - max(lst) )

Solution (Python):
i = list(map(int, input().split()))
n = i[0]
l = i[1]
if l >= 0:
    print(round((n-1)*(2*l+n)/2))
elif l+n-1 <= 0:
    print(round((n-1)*(2*l+n-2)/2))
else:
    print(round(n*(2*l+n-1)/2))

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

Solution (Python):
n,l = map(int,input().split())
taste = [l+i-1 for i in range(1,n+1)]
ideal = sum(taste)
bited = [ideal-taste[i] for i in range(n)]
dif = [abs(ideal-bited[i]) for i in range(n)]
print(bited[dif.index(min(dif))])

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

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

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

Solution (Python):
n, l = map(int, input().split(" "))
m = [l+i-1 for i in range(1, n+1)]

t = 100
total = 0
for mi in m:
    total += mi
    if abs(t) > abs(mi):
        t = mi
print(total - t)

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

Solution (Python):
def main():
    n, l = map(int, input().split())
    flavor = []
    for i in range(n):
        flavor.append(i + l)

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

    print(ans)

if __name__ == '__main__':
    main()

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

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

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

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

if apple[0] < 0:
    if apple[-1] > 0:
        taste = sum(apple)
    else:
        taste = sum(apple[:n-1])
else:
    taste = sum(apple[1:])

print(taste)

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

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

array = []

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

t = sorted(array,  key=lambda x: abs(x))
t.pop(0)

ans = 0
for i in t:
    ans += i
print (ans)

Solution (Python):
n,l = map(int,input().split())
taste = [l+i-1 for i in range(1,n+1)]
ideal = sum(taste)
bited = [ideal-taste[i] for i in range(n)]
dif = [abs(ideal-bited[i]) for i in range(n)]
print(bited[dif.index(min(dif))])

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

t = [L + _ - 1 for _ in range(1, N+1)] 
t = sorted(t, key=lambda x: abs(x))

"""
abseat = 299
eat = 299

for i in range(N):
    abst = abs(t[i])
    if abst < abseat:
        abseat = abs(t[i])
        eat = t[i]

ans = sum(t) - eat
"""
ans = sum(t) - t[0]
print(ans)

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

t = [L + _ - 1 for _ in range(1, N+1)] 
abseat = 299
eat = 299

for i in range(N):
    abst = abs(t[i])
    if abst < abseat:
        abseat = abs(t[i])
        eat = t[i]

ans = sum(t) - eat
print(ans)

Solution (Python):
N, L = (int(a) for a in input().split())
if N + L -1 < 0:
    x = N + L -1
elif L < 0 and N + L -1 >= 0:
    x = 0
else:
    x = L
sum = 0
for i in range(1,N+1):
    if x == L + i - 1:
        continue
    sum += L + i - 1
print(sum)

Solution (Python):
N, L = (int(a) for a in input().split())
if N + L -1 < 0:
    x = N + L -1
elif L < 0 and N + L -1 >= 0:
    x = 0
else:
    x = L
sum = 0
for i in range(1,N+1):
    if x == L + i - 1:
        continue
    sum += L + i - 1
print(sum)

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

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


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


b=[abs(a[i]) for i in range(n)]

temp=0


for i in range(n-1):
  if b[i+1]<b[i]:
    temp=i+1

a.pop(temp)
print(sum(a))

Solution (Python):

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

app = list(range(-1+a[1]+1,a[0]+a[1]-1+1))
apabs = list(range(-1+a[1]+1,a[0]+a[1]-1+1))

for i in range(len(app)):
    if app[i]<0:
        apabs[i]=app[i]*-1
    else:
        apabs[i]=app[i]
if min(apabs) == abs(max(app)):
    k=max(app)
    out=sum(app)-k
else:
    k=min(apabs)
    out=sum(app)-k        
    
print(out)

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

Solution (Python):
n, l = map(int, input().split())
taste = []
for i in range(1, n + 1):
    taste.append(l + i - 1)

max_pie = sum(taste)

min_diff = 10 ** 9
second_pie = 10 ** 9
for i in range(n):
    small_pie = sum(taste[:i]) + sum(taste[i + 1:])
    diff = abs(small_pie - max_pie)
    if diff < min_diff:
        min_diff = diff
        second_pie = small_pie
print(second_pie)

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

Solution (Python):
n, l = map(int, input().split())
ll = []
lmin = 1000
index = 0
for i in range(0, n):
	t = l + i
	ll.append(t)
	if lmin > abs(t):
		lmin = abs(t)
		index = i

del ll[index]
print(sum(ll))

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

'''
N, L = int(N), int(L)
min_pos = 9999999
min_neg = -9999999
sum = 0
for i in range(1,N+1):
    sum+=int(L)+i-1
for i in range(N):
    t = L + i
    
    if t >= 0:
        if min_pos > t:
            min_pos = t
    elif min_neg < t:
        min_neg = t
if min_pos > abs(min_neg):
    print(sum-min_neg)
else:
    print(sum - min_pos)

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

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

Solution (Python):
import sys
from math import ceil

def input():
    return sys.stdin.readline().strip()

def iinput():
    return int(input())

def finput():
    return float(input())

def tinput():
    return input().split()

def rinput():
    return map(int, tinput())

def rlinput():
    return list(rinput())

def nok(a, b):
    m = a * b
    while a != 0 and b != 0:
        if a > b:
            a %= b
        else:
            b %= a
    return m // (a + b)    


def main():
    n, l = rinput()
    a = []
    for i in range(n):
        a.append(l + i)
    w = sum(a)
    if a[0] >= 0:
        print(w - a[0])
    elif a[-1] <= 0:
        print(w - a[-1])
    else:
        print(w)
            
        
    
    
    
    
main()

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

Solution (Python):
N,L = map(int,input().split())
inf = float('inf')
eat = inf
ans = 0
for i in range(N):
    eat = min(eat, abs(L+i))
if L > 0:
    s = eat - L + 1
else:
    s = abs(eat + L -1)

for i in range(1,N+1):
    if s == i:
        continue
    ans += L + i -1
print(ans)

Solution (Python):
n, l = map(int, input().split())
apples = range(l, l + n)
taste = sum(apples)
if 0 in apples:
    pass
elif apples[0] > 0:
    taste -= apples[0]
else:
    taste -= apples[-1]
print(taste)

Solution (Python):
n,l=map(int,input().split())
aji=[l+_ for _ in range(n)]


if 0 in aji:
    print(sum(aji))
else:
    kei=sum(aji)
    if max(aji)<0:
        print(kei-max(aji))
    else:
        print(kei-min(aji))

Solution (Python):
N, L = map(int, input().split())
A = [L + i for i in range(N)]
m = min(A, key=abs)
A.remove(m) if m in A else A.remove(-m)
print(sum(A))

Solution (Python):
N, L = map(int, input().split())
A = [L + i for i in range(N)]
m = min(map(abs, A))
A.remove(m) if m in A else A.remove(-m)
print(sum(A))

Solution (Python):
from operator import add
from functools import reduce

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

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

if L < 0 and abs(L) >= N:
    l.pop(-1)
elif L < 0 and abs(L) < N:
    pass
else:
    l.pop(0)

print(reduce(add, l))

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

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

min_diff = 10000
min_num = 0
aa = 0
for x in range(l,l+n):
    aa += x
    if min_diff > abs(x):
        min_diff = abs(x)
        min_num = x

print(aa - min_num)

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

a = [abs(L+i-1) for i in range(1,n+1)]

min_a = a.index(min(a))
result = 0
for i in range(n):
    if i != min_a:
        result += L+i+1-1
    else:
        continue
print(result)

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

A_list = []
aji = 0

for i in range(N):
    A_list.append(L + i)
    aji += (L + i)




x = min(A_list,key= lambda A_list:abs(A_list))


aji -= x
print(aji)

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

r=[]
m=250
for i in range(n):
  r.append(l+i+1-1)
  if abs(l+i+1-1)<abs(m):
    m=l+i+1-1
  
r.remove(m)
print(sum(r))

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

ret = float('inf')
index = None
for i in range(1, n + 1):
    if ret > abs(total - (total - (l + i - 1))):
        ret = abs(total - (total - (l + i - 1)))
        index = i
print(total - (l + index - 1))

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

Solution (Python):
n, l = map(int, input().split())
t = []
for i in range(1, n+1):
  t.append(l+i-1)
t_s = sorted(t, key=abs)
print(sum(t) - t_s[0])

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

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

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

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

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

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

min_abs = abs(T[0])
min_abs_i = 0

for i, ti in enumerate(T):
    
    abs_ti = abs(ti)
    if abs_ti < min_abs:
        min_abs_i = i
        min_abs = abs_ti





ans = sum(T) - T[min_abs_i]
print(ans)

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

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

if T[0] >= 0:
    ans = sum(T[1:])
elif T[-1] <= 0:
    ans = sum(T[:-1])
else:
    for ti in T:
        if ti >= 0:
            min_plus = ti
            break
    ans = sum(T) - min_plus

print(ans)

Solution (Python):
n, l = map(int, input().split())
lst_l = list(range(l, l + n))
if 0 in lst_l:
    print(sum(lst_l))
else:
    if max(lst_l) > 1:
        print(sum(lst_l[1:]))
    else:
        print(sum(lst_l[:-1]))

Solution (Python):
N,L = map(int, input().split())
azi = N*L+(N*(N-1)//2)

minazi = 100
for i in range(1,N+1):
    if abs(L+i-1) < abs(minazi):
        minazi = L+i-1
print(azi-minazi)

Solution (Python):
n, l = (int(i) for i in input().split())
ans = 0
flg = 0
temp = 1000
for i in range(n) :
  sum =  l + (i + 1) - 1
  if sum == 0 :
    flg = 1
  elif temp > abs(sum) :
    temp = abs(sum)
    min = sum
  ans += sum
if flg == 1 :
  print(ans)
else :
  print(ans - min)

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

Solution (Python):
n, l= map(int, input().split())
apple = range(l, l+n)
cnt = sum(apple)
min = cnt
for i in apple:
    if abs(min) > abs(i):
        min = i 
print(cnt - min)

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

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

else:
    for i in range(1, N):
        if abs(apple_list[i]) < abs(apple_list[tmp]):
            tmp = i

    apple_list.remove(apple_list[tmp])
    print(sum(apple_list))

Solution (Python):
n,l=map(int,input().split())
r=[]
t=0
for i in range(1,n+1):
    r.append(int(l+i-1))
zero =0 in r
if zero==0 and r[0]>0:
    r.pop(0)
elif zero==0 and r[0]<0:
    r.pop(n-1)
elif zero==1:
    r.remove(0)
for i in range(n-1):
    t+=r[i]
print(t)

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

base = sum(t)
ans = -1
r = float('inf')
for j in range(N):
    if abs(t[j]) < r:
        r = abs(t[j])
        ans = j
print(base-t[ans])

Solution (Python):
import numpy as np


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


taste = np.arange(L, L + N, 1)


if np.min(taste) >= 0 and np.max(taste) >= 0:
  print("{}".format(np.sum(taste) - np.min(taste)))


elif np.min(taste) <= 0 and np.max(taste) <= 0:
  print("{}".format(np.sum(taste) - np.max(taste)))


else:
  print("{}".format(np.sum(taste)))

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

Solution (Python):

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