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

n_sum = (l*n)+sum(list(range(1,n+1)))-n
ans = n_sum

if l+n-1<=0:
    ans -= l+n-1
elif l>=0:
    ans -= l

print(ans)

Solution (Python):
N,L = map(int,input().split())
a = list()
ans = 0
wa = 0
for i in range(1,N+1):
  a.append(L+i-1)
  ans += L+i-1
mi = 10**7
for i in range(N):
  if abs(a[i]) < mi:
    mi = abs(a[i])
    wa = a[i]
print(ans-wa)

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

if l >= 0:
    print(sum(taste)-taste[0])
elif l+n-1 < 0:
    print(sum(taste)-taste[-1])
else:
    print(sum(taste)-taste[-l])

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

dif = float('inf')

for a in aji:
    SSum = Sum - a
    
    if abs(Sum - SSum) < dif:
        dif = abs(Sum - SSum)
        ans = SSum
    
print(ans)

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

Solution (Python):

n, l = map(int, input().split())
data = [l] * n
ans = 0

for i in range(n):
    data[i] += i
    ans += data[i]

mini = abs(data[0])
temp = data[0]

for i in range(n):
    if mini > abs(data[i]):
        mini = abs(data[i])
        temp = data[i]

print(ans - temp)

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

A = []
min_app = 100100100100
for i in range(1, N+1):
    app = L + i - 1
    A.append(app)
    if abs(min_app) > abs(app):
        min_app = app
print(sum(A) - min_app)

Solution (Python):
from sys import stdin

n, l = (int(x) for x in stdin.readline().rstrip().split())
t = [l+i-1 for i in range(1, n+1)]
if 0 in t:
    print(sum(t))
else:
    if sum(t) < 0:
        t.pop(-1)
        print(sum(t))
    else:
        t.pop(0)
        print(sum(t))

Solution (Python):

n,l=map(int,input().split())
a=[l+i for i in range(n)]
a_abs=[abs(l+i) for i in range(n)]
s=(2*l+n-1)*n//2
print(s-a[a_abs.index(min(a_abs))])

Solution (Python):
n, l = map(int, input().split())
taste = [l+i-1 for i in range(1, n+1)]
sm = sum(taste)
mn = 10**4
ans = 0
for i in range(n):
  if abs(sm - (sm-taste[i])) < mn:
    mn = abs(sm - (sm-taste[i])) 
    ans = sm-taste[i]
print(ans)

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

tastes = [L + i for i in range(N)]
print(sum(tastes) - min(tastes, key=abs))

Solution (Python):
n,l=map(int,input().split())
a=[]
for i in range(n):
    a.append(i+l)
x=10**10
for i in range(n):
    if abs(a[i])<x:
        x=abs(a[i])
        y=a[i]

print(sum(a)-y)

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

allpie = 0
for i in range(n):
    a = l+(i+1)-1
    allpie += a
    if i == 0:
        t = abs(a)
        num = i
    elif t > abs(a):
        t = abs(a)
        num = i


print(allpie-(l+(num+1)-1))

Solution (Python):
n,k=map(int,input().split())
sum=k
tmp=k
for i in range(1,n):
  sum+=k+i
  if abs(tmp)>abs(k+i):
    tmp=k+i
print(sum-tmp)

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

Solution (Python):
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007



def main():
	n , l = IN()
	al = [l+i-1 for i in range(1,n+1)]
	al=sorted(al, key = lambda v : abs(v))
	ret = sum(al)-al[0]
	
	print(ret)
	
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

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

org=0
for i in range(n):
        org+=(l+i)

ans=0
mn=10**9
for i in range(n):
        sm=0
        for j in range(n):
                if i==j:
                        continue
                sm+=l+j
        dif = abs(org-sm)
        if mn > dif:
                ans=sm
                mn=dif
print(ans)

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

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

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

L_max= N + L -1
ans = (L + L_max) * N // 2

if L * L_max <= 0:
    print(ans)
elif ans > 0:
    print(ans - L)
else:
    print(ans - L_max)

Solution (Python):
N,L = map(int,input().split())
import bisect
A = [i+L for i in range(N)]
ans = sum(A)-A[min(bisect.bisect_left(A,0),len(A)-1)]
print(ans)

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

apples = [l + i for i in range(n)]
taste = sum(apples)
apple_min = 1000
for i in range(n):
    if abs(apples[i]) < abs(apple_min):
        apple_min = apples[i]
taste -= apple_min
print(taste)

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

p = [0]*n
for i in range(n):
  p[i] = l + (i + 1) - 1

s = p[0]
for i in p:
  if abs(i) < abs(s):
    s = i

print(sum(p) - s)

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

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

if L > 0:
    eat = L
elif L+N-1 < 0:
    eat =  L+N-1
else:
    eat = 0

print(s-eat)

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

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

min_diff = 1000
min_taste = 0
for i in range(N):
    apple = L + i
    diff = abs(apple)
    if min_diff > diff:
        min_diff = diff
        min_taste = total - apple

print(min_taste)

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

Solution (Python):



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

if __name__=='__main__':
  main()

Solution (Python):
n, l = [int(i) for i in input().split()]
lst = [(i + 1 + l - 1) for i in range(n)]
lst_abs = [abs(i) for i in lst]
idx = lst_abs.index(min(lst_abs))
print (sum(lst[0:idx] + lst[idx + 1:]))

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

b = n + a - 1
s = (a + b) * n // 2

if a * b <=  0: 
    print(s)
else: 
    print(s - a) if s > 0 else print(s - b)

Solution (Python):
N, L = [int(s) for s in input().split(' ')]
ret = 0
start = L + 1 - 1
end = L + N - 1
if start * end <= 0:
    ret = [L + i - 1 for i in range(1, N + 1)]
elif start < 0:
    ret = [L + i - 1 for i in range(1, N)]
else:
    ret = [L + i - 1 for i in range(2, N + 1)]

print(sum(ret))

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

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

(N, L) = [int(n) for n in input().split()]

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

apples.sort()
if apples[0] in apples2:
    print(sum(apples2) - apples[0])
else:
    print(sum(apples2) + apples[0])

Solution (Python):
n, l = list(map(int, input().split(' ')))
m = 9999999999
apples = []
for i in range(n):
    if abs(m) > abs(i+l):
        m = i+l
    apples.append(i+l)
print(sum(apples) - m)

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

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

Solution (Python):
N_ko, L_aji = map(int, input().split())

taste = list(L_aji + i for i in range(N_ko))
taste.sort()

if (taste.count(0) > 0):
    ans = sum(taste)
elif (min(taste) > 0):
    ans = sum(taste[1:])
else:
    ans = sum(taste[:-1])

print(ans)

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

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

Solution (Python):
import numpy as np

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

min_abs=10**5
for i in range(N):
    if abs(sum(taste)-(sum(taste)-taste[i]))<min_abs:
        min_abs=abs(taste[i])
        rec=taste[i]
        
        
        
print(sum(taste)-rec)

Solution (Python):
N, L = map(int, input().split())
Ringo = sum([i+L-1 for i in range(1,N+1)])
ans = 1e+09
for j in range(1,N+1):
  Ringo2 = sum([i+L-1 for i in range(1,N+1) if i != j])
  tem = abs(Ringo - Ringo2)
  ans = min(ans, tem)
print(Ringo-ans if Ringo > Ringo2 else Ringo+ans)

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

k = []

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

k = sorted(k,key = lambda x:x[0])

ans = 0
for i in range(1,n):
    ans += k[i][1]
print(ans)

Solution (Python):

n,l = map(int, input().split())
ans = sum(range(l,l+n)) - min(range(l,l+n), key=abs)
print(ans)

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

def min_index(list):
    return [i for i, x in enumerate(list) if x == min(list)][0]

abs_ringo = [abs(i) for i in ringo]
ans = sum(ringo) - ringo[min_index(abs_ringo)]

print(ans)

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

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

sa = abs(all_app-aji[0])
ans = 0
for i in aji:
    if abs(all_app - i) <= sa: 
        sa = abs(all_app - i)
        ans = i

print(ans)

Solution (Python):
N,L=map(int,input().split())
taste=range(L,L+N)
print(sum(taste)-min(taste,key=abs))

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

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

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

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

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

apple.sort(key=abs)
print(sum(apple)-apple[0])

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

aji_total = int(N * L + N * (N-1) / 2)
aji_min = L
aji_max = L + N - 1

ans = 0
if aji_min >= 0:
  ans = aji_total - aji_min
elif aji_max >= 0:
  ans = aji_total
else:
  ans = aji_total - aji_max

print(ans)

Solution (Python):
N,L=map(int,input().split())
l=range(L,L+N)
print(sum(l)-min(l,key=abs))

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

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

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

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

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

d = [l + i for i in range(n)]
pre_d = sum(d)
mi = 100 * 200
for i in d:
    if i == 0:
        ans = pre_d
        break
    else:
        dif = abs(pre_d - (pre_d - i))
        if dif < mi:
            mi = dif
            ans = pre_d - i

print(ans)

Solution (Python):

N, L = map(int, input().split())
sum_all = N*(L+((N+1)/2)-1)

if L*(L+N-1) <= 0:
  print(int(sum_all))
elif L < 0:
  print(int(sum_all - L - N + 1))
else:
  print(int(sum_all - L))

Solution (Python):
x,y = map(int,input().split())
ans = 1000000000000000000000000000000
apple = 0
for i in range(1, x+1):
    apple += i+y-1
    ans = min(ans, abs(i+y-1))


if abs(apple-ans) <= abs(apple+ans):
    print(apple-ans)
else:
    print(apple+ans)

Solution (Python):


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


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

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

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

ans=0
_list=[]
for i in range(n):
    _list.append(l+i)

min_index=0
_min=10**10

for i in range(n):
    if abs(_list[i])<=_min:
        min_index=i
        _min=abs(_list[i])

print(sum(_list[:min_index])+sum(_list[min_index+1:]))

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, L = MAP()

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

mi = INF
for i in range(N):
	if azi[i] < 0:
		d = azi[i]*-1
	else:
		d = azi[i]
	if d < mi:
		mi = d
		index = i

print(sum(azi[0:index]) + sum(azi[index + 1:N]))

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

ans=10**6
p=-1
for j in range(N):
  tmp = abs(L+j)
  if tmp < ans:
    ans = tmp
    p = j
print(taste -(L+p))

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

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

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

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

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

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

tmp = [sum(tastes) - tastes[i] for i in range(n)]
tmp2 = [abs(sum(tastes)-v) for v in tmp]
print(tmp[tmp2.index(min(tmp2))])

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

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

apple_1 = L
apple_2 = L+N-1

if apple_1*apple_2<=0:
    apple_min=0
elif apple_1<=0 and apple_2<=0:
    apple_min=apple_2
else:
    apple_min=apple_1

sum=0
for i in range(N):
    sum+=L+i
sum-=apple_min
print(sum)

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

Solution (Python):
def main():
    N, L = (int(i) for i in input().split())
    s = 0
    li = []
    for i in range(1, N+1):
        s += L + i - 1
        li.append((abs(L + i - 1), i))
    li.sort()

    print(s - (L + li[0][1] - 1))


if __name__ == '__main__':
    main()

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

Solution (Python):
N, L = map(int, input().split())
ans = 0
tmp = 300
for i in range(N):
    if abs(L + i) < tmp:
        tmp = abs(L + i)
        num = i
        
for i in range(N):
    ans += (L + i)

ans -= (L + num)

print(ans)

Solution (Python):



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

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

for i in range(n):
    abs_a.append(abs(a[i]))    

if max(a)<0:
    p=pi+min(abs_a)
else:
    p=pi-min(abs_a)
    
print(p)

Solution (Python):
n,l=map(int,input().split())
pi=0
a=[]
abs_a=[]
for i in range(1,n+1):
    pi+=l+i-1

for i in range(1,n+1):
    a.append(l+i-1)

for i in range(n):
    abs_a.append(abs(a[i]))    

if max(a)<0:
    p=pi+min(abs_a)
else:
    p=pi-min(abs_a)
    
print(p)

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

Solution (Python):
import sys

n, l = map(int, sys.stdin.readline().split())

def main():
    s = (l - 1) * n + (1 + n) * n // 2
    res = []
    for i in range(1, n+1):
        f = l + i - 1
        res.append((abs(f), s - f))
    
    res.sort()
    return res[0][1]

if __name__=='__main__':
    ans = main()
    print(ans)

Solution (Python):
import sys
import numpy as np 

n, l = map(int, sys.stdin.readline().split())

def main():
    f = l + np.arange(1, n+1) - 1
    s = f.sum()
    a = np.absolute(f)
    mi = np.amin(a)
    i = np.argwhere(a == mi)[0, 0]
    return s - f[i]

if __name__ == '__main__':
    ans = main()
    print(ans)

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

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

Solution (Python):
N, L = map(int, input().split())
*a, = map(lambda x:L+x-1, range(1, N+1))
a.sort(key=abs)
print(sum(a)-a[0])

Solution (Python):
n,l=map(int,input().split())
p=[i+l-1 for i in range(1,n+1)]
q=[abs(i+l-1) for i in range(1,n+1)]
m=min(q)
s=sum(p)
if m in p:print(s-m)
else:print(s+m)

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

if L <= 0 <= L+N-1:
  a = L
  b = L+N-1
elif 0 < L:
  a = L+1
  b = L+N-1
else:
  a = L
  b = L+N-2

ans = 0
for i in range(a, b+1):
  ans += i
print(ans)

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

Solution (Python):




def main():
    N, L = map(int, input().split())
    result = []
    for i in range(N):
        result.append([i + L, abs(i + L)])
    result.sort(key=lambda x: x[1])
    result.pop(0)

    print(sum([r[0] for r in result]))


if __name__ == "__main__":
    main()

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


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

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

m = max(taste)
for e in taste:
  if abs(e) < m:
    m = abs(e)
print(sum(taste) - m)

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

if 0 in apples:
    print(sum(apples))
elif apples[0] > 0:
    print(sum(apples)-min(apples))
else:
    print(sum(apples)-max(apples))

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

Solution (Python):
n, a = map(int, input().split())
ans = 0
mi = 100000000
for i in range(0, n):
    if abs(mi)>abs(a): mi=a
    ans += a
    a += 1
print(ans-mi)

Solution (Python):
N, L = (int(nl) for nl in input().split())
tastes = [L+i-1 for i in range(1, N+1)]
min_taste = 100
min_taste_abs = 100
for taste in tastes:
    if min_taste_abs >= abs(taste):
        min_taste_abs = abs(taste)
        min_taste = taste

min_taste_index = tastes.index(min_taste)
if len(tastes) == min_taste_index+1:
    print(sum(tastes[:min_taste_index]))
else:
    print(sum(tastes[:min_taste_index]+tastes[min_taste_index+1:]))

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

a = 0
d = 101
for i in range(N):
    a += L + i
    if abs(d) >= abs(L + i):
        d = L + i

print(a - d)

Solution (Python):
n,l = map(int,input().split())
p1 = [(l+i-1) for i in range(1,n+1)]
p2 = [i**2 for i in p1]
num = p2.index(min(p2))
sums = sum(p1)-p1[num]
print(sums)

Solution (Python):
n, l = map(int, input().split())
taste = 0
eat = l + n - 1
for i in range(1, n+1):
    _taste = l + i - 1
    taste += _taste
    if abs(_taste) < abs(eat):
        eat = _taste

print(taste - eat)

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

lis = sorted([int(x) for x in range(l,l+n)], key = abs)
print(sum(lis[1:]))

Solution (Python):

from sys import stdin
from copy import deepcopy
from functools import reduce
from fractions import gcd
import math
import itertools
from collections import Counter
from itertools import chain  
from heapq import heappush, heappop

"""
N = int(input())
A, B = map(int,input().split())
A = list(map(int,input().split())) 
A = [int(input()) for _ in range(N)] 
lst = [list(map(int,input().split())) for i in range(M)] 
"""

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

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

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

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

if max(x)*min(x)<=0:
    print(sum(x))
elif min(x)>0:
    print(sum(x)-min(x))
elif max(x)<0:
    print(sum(x)-max(x))

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

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

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

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

sum_n = 0
min = 1000
ans = 0

for i in range(1, n+1):
    sum_n += L + i -1

    if(abs(L+i-1) < min):
        min = abs(L+i-1)
        ans = L+i-1
print(sum_n-ans)

Solution (Python):
a = input().split()
N, L = [int(i) for i in a]
l = []
for i in range(1,N+1):
  dif = abs(L+i-1)
  l.append(dif)
m = l.index(min(l)) + 1
sol = N*L + (N-1)*N/2 - (L+m-1)
print(int(sol))

Solution (Python):
N,L=map(int,input().split())
taste=list(range(L,N+L))
 
taste2=[]
for i in range(N):
    taste2.append((taste[i])**2)
 
X=0
for i in range(N):
    if taste2[i]==min(taste2):
        X+=taste[i]
        
print(sum(taste)-X)

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

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

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

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

apple_sum = 0
apple_min = 1000
apple_min_index = -1

for i in range(n):
    apple_sum += i+l
    if apple_min > abs(i+l):
        apple_min = abs(i+l)
        apple_min_index = i

ans = 0
for i in range(n):
    if i != apple_min_index:
        ans += i+l

print(ans)

Solution (Python):
import numpy as np
N, L = map(int, input().split())
aji = np.array(list(range(1,N+1))) + L - 1

def getNearestValue(list, num):
    idx = np.abs(np.asarray(list) - num).argmin()
    return list[idx]

answer = sum(aji) - getNearestValue(aji, 0)
print(answer)

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

for i in range(1,n+1):
	y.append(l + i -1)

if 0 in y:
	print(sum(y))
elif sorted(y)[-1] < 0:
	print(sum(sorted(y)[:-1]))
elif sorted(y)[0] > 0:
	print(sum(sorted(y)[1:]))

Solution (Python):
n, l = map(int, input().split())
taste = [i for i in range(l, l + n)]
SUM = sum(taste)
diff = 10 ** 3
idx = 0
for j in range(len(taste)):
    diff_n = abs(taste[j])
    if diff_n < diff:
        idx = j
        diff = diff_n
        if diff == 0:
            print(SUM)
            exit(0)
print(SUM-taste[idx])

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

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

Solution (Python):
N,L=map(int,input().split())
J=[]
for i in range(N):
    J.append(L+i)
for i in J:
    if i == 0:
        J.pop(J.index(0))
        print(sum(J))
        exit(0)
J.sort()
print(sum(J[1:]) if J[0]>0 else sum(J[:-1]))

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

Solution (Python):
n,l=map(int,input().split())
d=abs(l)
pie=(n*(n+1)//2)+(n-1)*(l-1)-1
for k in range(2,n+1):
    t_pie=((n*(n+1))//2)+n*(l-1)
    p_pie=((n*(n+1))//2)+(n-1)*(l-1)-k
    xd=abs(t_pie-p_pie)
    if xd <= d:
        d=xd
        pie=p_pie
print(pie)

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

Ts = []
for idx in range(1, N+1):
    taste = idx + L - 1
    Ts.append(taste)

min_t = 20000000000
total = sum(Ts)
for t in Ts:
    if abs(t) < abs(min_t):
        min_t = t
print(total-min_t)

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

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

Solution (Python):
n,l=(int(x) for x in input().split())
a=[]
for i in range(n):
  a.append(l+i)
m=abs(a[0])
for i in range(1,n):
  if abs(a[i])<m:
    m=abs(a[i])
s=0
for i in range(n):
  if abs(a[i])!=m:
    s+=a[i]
print(s)

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

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

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

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

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

tmplst = []
for x in lst:
    if x < 0:
        tmplst.append(-x)
    else:
        tmplst.append(x)
place = tmplst.index(min(tmplst))
lst.remove(lst[place])
print(sum(lst))

Solution (Python):
N, L = map(int, input().split())
t = sorted(list(range(L, L+N)), key=abs)
print(sum(t[1:]))

Solution (Python):


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

mn = 0
if n + l -1 < 0:
    mn = max([i + l -1 for i in range(1, n+1)])
elif 1 + l - 1 >= 0:
    mn = min([i + l -1 for i in range(1, n+1)])

print(sum(i + l - 1 for i in range(1, n+ 1)) - mn)

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

A = [L+i for i in range(N)]
d = 99999999
for i in range(N):
  if abs(A[i])<d:
    d = abs(A[i])
    ans = sum(A)-A[i]
print ans

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

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

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

x = 10 ** 9
y = 0

for apple in apples:
    if abs(apple) < x:
        x = abs(apple)
        y = apple
print(sum(apples)-y)

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

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

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

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

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

min = 10**9
ind = -1
for i in range(1,n+1):
    diff = abs(l+i-1)
    if diff < min:
        min = diff
        ind = i

print(sum_n - (l+ind-1))

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

Solution (Python):

n,l=map(int,input().split())
aji=[i+l-1 for i in range(1,n+1)]
eat=100100
for x in aji:
    if abs(eat)>abs(x):
        eat=x
ans=sum(aji)-eat
print(ans)

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

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

print(sum(A[1:]))

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

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

abs_x = 1000
x = 0
total = 0
for i in range(n):
  total += l + i
  if abs_x > abs(l + i):
    x = l + i
    abs_x = abs(l + i)
print(total - x)

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

minNL = 101

for j in range(N):
    if listNL[j] == 0:
        minNL = 0
    elif listNL[j] > 0:
        minNL = min(minNL, listNL[j])
    else:
        minNL = (-1)*(min(abs(minNL), abs(listNL[j])))
    

print(sumNL - minNL)

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

list = list(range(L, L+N))
min = 1000
bite = 0
for i in list:
    if min > abs(i):
        min = abs(i)
        bite = i
            
print(sum(list) - bite)

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