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

aji_sum=0
eat=99999

for i in range(1,N+1):
    
    aji_sum=aji_sum+i+L-1
    if abs(i+L-1) < abs(eat):
        eat = i+L-1

print(aji_sum-eat)

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

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

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

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

edge=[L, L+N-1]
if edge[0]*edge[1]<=0:
  ans=sum(edge)*N/2
elif edge[0]>0:
  ans=(L+1+L+N-1)*(N-1)/2
else:
  ans=(L+L+N-2)*(N-1)/2
  
print(int(ans))

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

Solution (Python):
import numpy as np
N,L = map(int, input() . split())
x=[]
M = 0
N_list = np.array([])

for i in range(N):
  M += L + (i+1) - 1
  N_list = np.append(N_list, L + (i+1) - 1)
  
m = np.abs(N_list).argmin()


print(int(M - N_list[m]))

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

absmini = 60000
mini = 60000
sum = 0

for i in range(b, b + a):
	if(absmini > abs(i)):
		absmini = abs(i)
		mini = i
	
	sum += i

print(sum - mini)

Solution (Python):

N,L = list(map(int, input().split()))
Ni = []
mI = 0
ab = abs(L - 1)
for i in range(N):
    if ab > abs(L + i):
        mI = i
        ab = abs(L + i)

    Ni.append(L + i)

del Ni[mI]
print(sum(Ni))

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

Solution (Python):
N,L=map(int,input().split())
t_1=0
t=[]
for i in range(1,N+1):
    t_1+=L+i-1
for j in range(1,N+1):
    t.append(abs(L+j-1))
print( t_1 - L - t.index(min(t)) )

Solution (Python):

import sys


def solve(N: int, L: int):
    abs_val = sys.maxsize
    flavor = 0
    for i in range(N):
        a = L + i
        flavor += a
        if abs(a) < abs_val:
            abs_val = abs(a)
            index = i
    print(flavor - (L + index))
    
    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 = list(map(int, input().split()))
sum = 0

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

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

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

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

if l>=0:
    print(m1-l)
else:
    if l>1-n:
        print(m1)
    else:
        print(m1-l-n+1)

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

count = 0
min = None
sum = 0
for i in range(N):
  i += 1
  num = abs(L + i - 1)
  if min == None:
    min = num
    count = i
    continue
  if min > num:
    min = num
    count = i
for i in range(N):
  i += 1
  if i != count:
    num = L + i - 1
    sum += num
print(sum)

Solution (Python):
n,l = map(int, input().split())
a = [0]*n


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

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

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

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

taste_list = []

for i in range(1, n+1):
    taste = l + i - 1
    taste_list.append(taste)

abs_taste_list = [abs(x) for x in taste_list]
target_index = abs_taste_list.index(min(abs_taste_list))
taste_list.remove(taste_list[target_index])
ans = sum(taste_list)
print(ans)

Solution (Python):
N, L = map(int, input().split())
llist = []
p = 0
zeronear = {}
for i in range(N):
    llist.append(L+i)
for i in range(len(llist)):
    zeronear[i] = abs(llist[i]-0)
a = min(zeronear, key=zeronear.get)
del llist[a]
print(sum(llist))

Solution (Python):

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

t = list(map(lambda i: L + i, range(N)))

targ = sum(t)
m = 10000000000000
res = 0
for c in t:
    now = targ - c
    if m > abs(targ - now):
        m = abs(targ - now)
        res = now

print(res)

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

Solution (Python):
n,l=input().split()
n=int(n)
l=int(l)
taste_1=[]
for x in range(1,n+1):
    taste_1.append(l+x-1)
taste_2=[]
for x in range(n):
    if taste_1[x]<0:
        taste_2.append(-taste_1[x])
    else:
        taste_2.append(taste_1[x])
t=sorted(taste_2)



ans=0
for a in range(n):
    ans+=taste_1[a]
if t[0] in taste_1:
    ans=ans-t[0]
else:
    ans=ans+t[0]
print(ans)

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

Solution (Python):
N,L = map(int,input().split())
s = 0
lst = []
for i in range(1,N+1):
  s += i + L - 1
  lst.append(abs(i+L-1))
if L >= 0:
  ans = s - min(lst)
else:
  ans = s + min(lst)
print(ans)

Solution (Python):

N, L = (int(_) for _ in input().split())
Dmin = 1000
Dsum = 0
for i in range(N):
    D = L + i
    Dsum += D
    Dmin = min(abs(D), Dmin)
if D < 0:
    print(Dsum + Dmin)
else:
    print(Dsum - Dmin)

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

if l>=0:
    for val in range(n-1):
        s += val+l+1
        


elif l < 0 and n > -l:
    for val in range(n):
        s += val + l
        
else:
    for val in range(n-1):
        s += val + l



print(s)

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

Solution (Python):
def main():
    N,L = map(int,input().split())
    aji_all = 0

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

    for i in range(1,N+1):
        aji_i = aji_all - (L + i - 1)
        if i == 1:
            best_score =  abs(aji_all - aji_i)
            best_num = i
            ans = aji_i
            
        if best_score > abs(aji_all - aji_i):
            best_score = abs(aji_all - aji_i)
            ans = aji_i
            best_num = i

    print(ans)

if __name__ == '__main__' :
    main()

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

N = [0 for i in range(n)]
NN = [0 for i in range(n)]

for j in range(n):
    N[j] = l + j
    NN[j] = abs(l+j)


if 0 in N:
    print(sum(N))
else:
    if min(N) == min(NN):
        N.remove(min(N))
    else:
        N.remove(max(N))


    print(sum(N))

Solution (Python):
import numpy as np
N, L = [int(x) for x in input().split(" ")]
quality = [(L + i - 1) + 1 for i in range(N)]

abs_quality = [abs(q) for q in quality]
ind = np.argmin(abs_quality)

taste = np.sum([q for i, q in enumerate(quality) if i != ind])
print(taste)

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

Solution (Python):
n, l = map(int, input().split())
tot = 0
for i in range(0, n):
    tot += l + i
dif = 100000000000
ans = 0
for i in range(0, n):
    a = tot - (l + i)
    if abs(tot - a) < dif:
        ans = a
        dif = abs(tot - a)
print(ans)

Solution (Python):
from sys import stdin


def main():
    N, L = [int(x) for x in stdin.readline().rstrip().split()]

    apple_list = []

    for i in range(N):
        apple_list.append(L+i)

    s = sorted(apple_list, key=abs)
    s.pop(0)
    print(sum(s))


if __name__ == "__main__":
    main()

Solution (Python):
from sys import stdin


def main():
    N, L = [int(x) for x in stdin.readline().rstrip().split()]

    apple_list = []

    for i in range(N):
        apple_list.append(L+i)

    s = sorted(apple_list, key=abs)
    s.pop(0)
    print(sum(s))


if __name__ == "__main__":
    main()

Solution (Python):
import numpy as np
N, L = map(int,input().split())
tast_list = [L + i for i in range(N)]
drop_iter = np.argmin(np.abs(tast_list))
del tast_list[drop_iter]
print(sum(tast_list))

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


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

if L <= 0 <= L+N-1:
    None
elif L > 0:
    value -= L
elif L+N-1 < 0:
    value -= L+N-1

print(value)

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

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

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

left = L
right = L + N - 1

sum = 0
for i in range(left, right + 1):
    sum += i

ans = sum
if left * right > 0:
    if abs(left) < abs(right):
        ans -= left
    else:
        ans -= right

print(ans)

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

def main():
	n, l = map(int, input().strip().split())
	a = [0] * n
	m = 10**9
	u = None
	for i in range(n):
		a[i] = l + i
		if abs(a[i]) < m:
			m = abs(a[i])
			u = i
	print(sum(a) - a[u])

if __name__ == '__main__':
	main()

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

eat=T.index(min(T))+1

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

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

taste_list = [l+i-1 for i in range(1,n+1)]
abs_taste_list = [abs(i) for i in taste_list]
min_index = abs_taste_list.index(min(abs_taste_list))
min = taste_list[min_index]
print(sum(taste_list)-min)

Solution (Python):

X = [int(el) for el in input().split(' ')]
n = X[0]
l = X[1]

A = [abs(l + i - 1) for i in range(1, n+1)]

j = A.index(min(A)) + 1
B = [(l + i - 1) for i in range(1, n+1) if i != j]
print(sum(B))

Solution (Python):
N,L= map(int,input().split())
aji = []
for i in range(1,N+1):
    aji.append(L+i-1)
if min(aji) >= 0:
    aji.pop(aji.index(min(aji)))
elif max(aji) <=0:
    aji.pop(aji.index(max(aji)))
else:
    aji.pop(aji.index(min(aji,key=abs)))
print(sum(aji))

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

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

print(sum(x)-min(x,key = abs))

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

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

min = 10000000

for apple in apples:
    if abs(apple) < min:
        min_index = apples.index(apple)
        min = abs(apple)
        
        
print(sum(apples)-apples[min_index])

Solution (Python):
N,L = map(int,input().split(' '))
X = []

for i in range(1,N+1):
  X.append(L+i-1)
res = float('inf')
print(sum(X)-min(X,key=abs))

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

max = N + L - 1
min = L

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

if max < 0:
    taste -= max
elif min > 0:
    taste -= min

print(taste)

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

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

x = 1000
p = -1

for i in range(N):
    y = abs(L + i)
    if y < x:
        x = y
        p = i
        
ans = (L-1) * N + N * (N + 1)/2 -(L + p)
print(int(ans))

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

for i in range(n):
    if i == 0:
        dif = abs(sum(apple[:i]+apple[i+1:]) - org)
        ans = sum(apple[i+1:])
    elif abs(sum(apple[:i]+apple[i+1:]) - org) < dif:
        dif = abs(sum(apple[:i]+apple[i+1:]) - org)
        ans = sum(apple[:i]+apple[i+1:])
print(ans)

Solution (Python):
a,b = map(int,input().split())
mx = 100000000
sum = 0
flag = False
for i in range(1,a+1):
    if mx > abs(b+i-1):
        mx = abs(b+i-1)
    if b+i-1 < 0 :
        flag = True
    sum+=b+i-1
if flag:
    print(sum+mx)
else:
    print(sum-mx)

Solution (Python):
a,b = map(int,input().split())
l = []
k = []
s = 0
aa = 1000000000
for i in range(a):
    l.append(b+i)
m = sum(l)
for i in l:
    if abs(i)<aa:
        aa = abs(i)
        s = i

print(sum(l)-s)

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

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

sm = sum(a)

d = 1000000

ch = 0

for i in range(len(a)):
    n = sm - a[i]
    if abs(n - sm) < d:
        d = abs(n-sm)
        ch = n

print(ch)

Solution (Python):
n, a = map(int, input().split())
L = a
R = a + n - 1
eat = 0
if R <= 0:
    eat = R
elif L >= 0:
    eat = L

ans = (R+L) * (R-L+1) / 2 - eat
print(int(ans))

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

mi = 1000000000000000000000
for i in range(n):
    b = a - l - i
    c = abs(a-b)
    if c < mi:
        mi = c
        minsum = b

print(minsum)

Solution (Python):
S = input()

S = list(map(int, S.split()))

N = S[0]
L = S[1]

taste_min = 100000000
taste = 0
for i in range(1, N+1, 1):
    taste = taste + L + i - 1

for i in range(1, N+1, 1):
    taste_temp = 0
    for j in range(1, N + 1, 1):
        if i != j:
            taste_temp = taste_temp + L + j - 1
    if abs(taste_temp-taste) < abs(taste_min-taste):
        taste_min = taste_temp

print(taste_min)

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

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

if tastes[0] * tastes[-1] < 0:
    ans = sum(tastes)
elif tastes[0] >= 0:
    ans = sum(tastes) - tastes[0]
else:
    ans = sum(tastes) - tastes[-1]

print(ans)

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

ret = -1
ans = 1e100
for x in X:
    if abs(x) <= ans:
        ans = min(ans, abs(x))
        ret = sum_X - x
print(ret)

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

ans_dif = float('inf')
ans = 0

for i in range(n):
  dif = abs(l+i)
  if dif < ans_dif:
    ans_dif = dif
    ans = n*l+n*(n+1)/2-n-(l+i)
print(int(ans))

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

elif a[0]>0:
    print(sum(a)-a[0])
elif a[n-1]<0:
    print(sum(a)-a[n-1])

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

taste = l
for i in range(l, l+n):
    if abs(i) < abs(taste):
        taste = i

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

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

for i in range(2, N+1):
    taste = L + i - 1
    if abs(taste) < abs(eatable_taste):
        eatable_taste = taste

print(int(N*(N-1)/2 + L*N - (eatable_taste)))

Solution (Python):
def B_BiteEating():
    N, L = map(int,input().split())
    eat = 0
    if L >= 0:
        eat = L
    elif L + N <= 0:
        eat = L + N - 1
    else:
        eat = 0
    print(sum([i for i in range(L, L + N)]) - eat)
    
if __name__ =="__main__":
    B_BiteEating()

Solution (Python):
def solve(string):
    n, l = map(int, string.split())
    _sum = l * n + n * (n - 1) // 2
    if l >= 0:
        _sum -= l
    elif l + n - 1 < 0:
        _sum -= l + n - 1
    return str(_sum)


if __name__ == '__main__':
    print(solve(input()))

Solution (Python):
kosu, aji = map(int, input().split())
mikaku = []
for k in range(1, kosu + 1):
  mikaku.append(k + aji - 1)
mikaku_dash = [abs(m) for m in mikaku]
point = mikaku_dash.index(min(mikaku_dash))
mikaku.remove(mikaku[point])
print(sum(mikaku))

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

Solution (Python):
n,l = map(int, input().split())
ls = []
minNum = 0
num = float('inf')
for i in range(1,n+1):
    ls.append(i+l -1)
    if num > abs(ls[i-1]):
        num = abs(ls[i-1])
        minNum = ls[i-1]
ls.pop(ls.index(minNum))
print(sum(ls))

Solution (Python):
import numpy as np
n,l=map(int,input().split())
li=[]
for i in range(n):
  li.append(l+i)
li2=sorted(li, key=abs)
print(sum(li2[1:]))

Solution (Python):
_input = input()
N, L = tuple([int(a) for a in _input.split(' ')])

def ans_func(I):
    return int(N*N/2 - N/2 + (N-1)*L + 1 - I)


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

Solution (Python):
N,L = map(int,input().split())
A = []
minidx = 0
for i in range(N):
  A += [L + i]
  if abs(A[i]) < abs(A[minidx]):
    minidx = i
ans = sum(A) - A[minidx]
print(ans)

Solution (Python):
import io
import sys


def IN_S():
  return input()


def IN_I():
  return int(input())


def IN_L_I():
  return list(map(int, input().split()))


def IN_L_S():
  return list(map(str, input().split()))


def STR_SPLIT(s, n):
  for l in range(0, len(s), n):
    yield s[0 + l:n + l]


def T_IN():
  global test_str
  sys.stdin = io.StringIO(test_str[1:-1])


test_str = '''
5 2
'''


def MAIN():
  
  A()


def A():
  n, l = IN_L_I()
  li = list([ i + l for i in range(0,  n)])
  if li.count(0) == 0:
    j = li.pop(0)
    k = li.pop(-1)
    if abs(j) < abs(k):
      li.append(k)
    else:
      li.append(j)

  print(sum(li))

  return None
 

def B():
  return None


def C():
  return None


MAIN()

Solution (Python):
N, L = map(int, input().split())
S = 0
T = 1000
ans = 0
flag = 1

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

for i in range(N):
    if T > abs(L+i) and L+i>=0:
        T = abs(L+i)
        flag = 1
    elif T > abs(L+i) and L+i<0:
        T = abs(L+i)
        flag = -1
        
ans = int(S-T*flag)
print(ans)

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

l = [L + i for i in range(N)]
item = l.index(min(l, key=abs))
ans = 0
for i, v in enumerate(l):
    if i == item:
        continue
    ans += v

print(ans)

Solution (Python):
n,l=[int(i) for i in input().split()]
arr=[]
for i in range(1,n+1):
    arr.append(l+i-1)
tot = sum(arr)
diff = 10**9
ans=0
for i in range(len(arr)):
    cur_diff = abs(tot - (tot-arr[i]))
    if(abs(tot-(tot-arr[i]))<diff):
        diff = abs(tot-(tot-arr[i]))
        ans = tot-arr[i]
print(ans)

Solution (Python):
N, L = map(int, input().split())
taste = [L + i - 1 for i in range(1, N+1)]
abs_diff_taste = [abs(x) for x in taste]
sum_taste = sum(taste)
min_diff = min(abs_diff_taste)
if sum_taste >= 0:
  print(sum_taste - min_diff)
else:
  print(sum_taste + min_diff)

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

def apple_aji(i):
  return int(l) + int(i) - 1

def remove_min(p):
  minimun = min(list(map(abs, p)))
  if minimun not in p:
    minimun = minimun * -1
  p.remove(minimun)
  return p

def apple_pie(n):
  ajis = [apple_aji(x) for x in n]
  return sum(remove_min(ajis))

print(apple_pie(range(1, int(n)+1)))

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

diff = float("inf")
ans = 0

for i in range(1, N+1):
    before = sum([L+k-1 for k in range(1, N+1)])
    after = sum([L+j-1 for j in range(1, N+1) if j != i])
	
    if abs(before-after) < diff:
    	diff = abs(before-after)
    	ans = after
print(ans)

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

ap = [L+i for i,v in enumerate(range(N))]

min_=10000
for c in ap:
    if abs(c)<min_:
        min_=abs(c)
        v=c

ap.remove(v)

print(sum(ap))

Solution (Python):
num, taste = map(int, input().split())

list = []

for i in range(taste, taste + num):
    list.append(i)

if list[0] > 0:
    list.pop(0)
    print(sum(list))
elif list[num-1] < 0:
    list.pop(num-1)
    print(sum(list))
else:
    print(sum(list))

Solution (Python):
N, L = map(int, input().split())
ll = []
l = []
a = 0
for i in range(L, L+N):
    ll.append(i)
    if i < 0 :
        i = -i
        a = 1
    l.append(i)

minl = min(l)
if a == 1 :
    minl = -minl
    print(sum(ll)-minl)
else :
    print(sum(ll)-minl)

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

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

min = 1000000
value = 0

for i, t in enumerate(T):
    if abs(t) < min:
        min = abs(t)
        value = t
    else:
        continue

print(sum(T) - value)

Solution (Python):
import math

def main():
    N, L  = list(map(int, input().split(" ")))
    minimum = abs(L-1+1)
    argmin = 1
    for i in range(2, N+1):
        value = abs(L-1+i)
        if value < minimum:
            minimum = value
            argmin = i
    ans = (N-1)*(L-1) + N*(N+1)/2 - argmin
    print(int(ans))

if __name__ == '__main__':
    main()

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

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

for i in range(n):
    if diff > abs(l + i):
        diff = abs(l + i)
        ans = taste - (l + i)
    
print(ans)

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

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

for i in range(n):
    if diff > abs(taste - (taste - (l + i))):
        diff = abs(taste - (taste - (l + i)))
        ans = taste - (l + i)
    
print(ans)

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

Solution (Python):
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]
def mi(n): return [wi() for _ in range(n)]
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]

n, l = wi()
a = []
for i in range(n):
    a.append(l + i)
sumn = sum(a)
b = []
for i in range(n):
    b.append([abs(sumn - (sumn - (l + i))), sumn - (l + i)])
b.sort()
print(b[0][1])

Solution (Python):
n,l=input().split()
n=int(n)
l=int(l)
taste=[]
abs_list=[]
for i in range(n):
  taste.append(l+i)
for j in range(len(taste)):
  abs_list.append(abs(taste[j]))
taste.pop(abs_list.index(min(abs_list)))
print(sum(taste))

Solution (Python):
def main08():
    data = input().split()
    nl = []
    for i in range(2):
        nl.append(int(data[i]))
    hantei = nl[0] + nl[1]
    result = 0
    if hantei <= nl[0] and 1 <= hantei:
        for i in range(nl[0]):
            result = result + nl[1] + i
    elif nl[1] > 0:
        for i in range(nl[0]-1):
            result = result + nl[1] + i + 1
    else:
        for i in range(nl[0]-1):
            result = result + nl[1] + i
    print(result)

if __name__ == "__main__":
    main08()

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

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

minnum = 10000
sumtaste = sum(taste)

for i in range(N):
    if abs(minnum) > abs(taste[i]):
        minnum = taste[i]


print(sumtaste-minnum)

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

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

if l > 0:
    ans = sum(apple) - apple[0]
elif (l + n - 1) >= 0:
    ans = sum(apple)
elif (l + n - 1) < 0:
    ans = sum(apple) - apple[-1]

print(ans)

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

if all(map(lambda x: x < 0, a)):
    ans = sum(a[:-1])
elif all(map(lambda x: x > 0, a)):
    ans = sum(a[1:])
else:
    ans = sum(a)

print(ans)

Solution (Python):
import numpy as np
N,L=map(int,input().split())
Taste=list(int(i) for i in range(L+1-1,L+N-1+1) )
MaxTaste=[sum(Taste)]*N
print(sum(Taste)-Taste[np.argmin(np.abs(np.array(Taste)))])

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

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

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

Solution (Python):
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
logging.disable(logging.CRITICAL)

def main():
    N, L = (int(x) for x in input().split())

    logging.info("Hello!")

    apples = [L - 1 + i for i in range(1, N + 1)]
    apples_abs = [abs(x) for x in apples]
    
    apple_pie_answer = sum(apples) - apples[apples_abs.index(min(apples_abs))]
    
    print(apple_pie_answer)
    
    
if __name__ == "__main__":
    main()

Solution (Python):
n,l = map(int,input().split())
mina = 300
s = 0
plus = True
for  i in range(1,n+1):
    if mina > abs(i+l-1):
        mina = abs(i+l-1)
        if i+l-1 > 0:
            plus = True
        else:
            plus = False
    s += i+l-1
if plus:
    print(s-mina)
else:
    print(s+mina)

Solution (Python):


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

applelist=[0 for i in range(n)]
for i in range(n):
	applelist[i]=l+i

if applelist[n-1]>=0:
	print(sum(applelist)-max(0,min(applelist)))
else:
	print(sum(applelist)-applelist[n-1])

Solution (Python):
N,L=list(map(int,input().split()))
taste=[]
taste1=[]
memo=[]
sum=0
for i in range(N):
    tasty=abs(L+i)
    if L+i<=0:
        memo.append(L+i)
    taste.append(tasty)
    taste1.append(L+i)
    sum+=taste1[i]
tasteab=sorted(taste)
memo=sorted(memo)
if memo!=[]:
    pie=(sum-memo[-1])
else:
    pie=(sum-tasteab[0])
print(pie)

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

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

else:
  print(int((2*L+N-1)*N/2))

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

Solution (Python):
n,l = map(int,input().split())
lis = []
for i in range(1,n+1):
    lis.append(l + i - 1)
m = 100
for i in lis:
    m = min(m,abs(i))
if not m in lis:
    lis.remove(m * (-1))
else:
    lis.remove(m)
print(sum(lis))

Solution (Python):
n,l = map(int,input().split())
nums = list(range(l,n+l))

mi = l
ma = n+l-1

if ma < 0:
    print(sum(nums)-ma)
elif mi > 0:
    print(sum(nums)-mi)
else:
    print(sum(nums))

Solution (Python):
N,L=map(int,input().split())
aji=0
Nlist=[x for x in range(L,L+N,1)]
Nabslist=[abs(Nlist[x]) for x in range(len(Nlist))]
Nmindex=Nabslist.index(min(Nabslist))
for i in range(len(Nlist)):
    if i==Nmindex:
        continue
    aji=aji+Nlist[i]
print(aji)

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

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

Solution (Python):
N, L = map(int, input().split())
taste = [L + i - 1 for i in range(1, N+1)]
s = sum(taste)
ans = s - min(taste) if all(t >= 0 for t in taste) else s - max(taste) if all(t < 0 for t in taste) else s
print(ans)

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

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

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

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

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

sum = 0
for i in range(n):
    sum += l + i
if l <= 0 and l + n - 1 >= 0:
    print(sum)
elif l < 0:
    print(sum - (n + l - 1))
elif l > 0:
    print(sum - l)

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

Solution (Python):



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

min = 2000000


ans = 0


for i in range(1,N+1):
    if (min > abs(L + i - 1)) :
        min = abs(L + i - 1)
        N_min = i

for j in range(1,N+1 ):
    if(j != N_min):  
        ans += L + j - 1

print(ans)

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

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

ab = []
for k in range(1, N+1):
    ab.append(abs(L + k - 1))

print(apple_pie - (L + ab.index(min(ab))  ))

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

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

origin = sum(taste)
choice = float('inf')

for t in taste:
    if abs(t) < abs(choice):
        choice = t

ans = origin - choice
print(ans)

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