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):
import sys

a = [int(i) for i in input().split()]
x=0
i=0
b=a[1]
while i < a[0]:
  x+=b
  b+=1
  i+=1
if a[1]>=0:
  x-=a[1]
  print(x)
elif a[1]<0 and a[0]+a[1]<=0:
  x=x-b+1
  print(x)
else:
  print(x)

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

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

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

if min(ajilist) <0 and max(ajilist)>=0:
    abso = 0
elif min(ajilist)<0 and max(ajilist)<0:
    abso = abs(max(ajilist))
else:
    abso=abs(min(ajilist))
    

for i in range(len(ajilist)):
    temp = abs(ajilist[i])
    if abso==temp:
        ajilist.pop(i)
        break
print(sum(ajilist))

Solution (Python):

N,L = map(int,input().split())
L2 = L
count=0
while L2 < 0:
    L2+=1
    count+=1

sum =0
if L < -49:
    j = N
else:
    j = N+1
for i in range(1,j):
    if i-1 != count:
        sum += L+i-1
print(sum)

Solution (Python):
from sys import stdin

class B:
	def __init__(self,N,L):
		self.N = int(N)
		self.L = int(L)
		self.taste = list()
		self.taste_abs = list() 


	def CollectTaste(self):
		for i in range(1,self.N+1):
			i = self.CulTasteFirst(i)
			self.taste.append(i)
			self.taste_abs.append(abs(i)) 

		
		min_num = min(self.taste_abs)
		try:
			self.taste.remove(min_num)
		except ValueError:
			min_num *= -1
			self.taste.remove(min_num)

		ans = 0
		for i in self.taste:
			ans += i
		print(ans)
	def CulTasteFirst(self,i):
		i = int(i)
		return self.L+i-1


Inp = stdin.readline()
Inp = Inp.replace('\n','')
Inp = Inp.split()

do = B(Inp[0],Inp[1])
do.CollectTaste()

Solution (Python):
N,L = map(int,input().rstrip().split(' '))
apple_pie = 0
ex = abs(L * N)
apple = []
for i in range(N):
    a = L + i 
    apple.append(a)
    apple_pie += a
for i in range(len(apple)):
    if abs(ex) > abs(apple[i]):
        ex = apple[i]
apple_pie-= ex
print(apple_pie)

Solution (Python):


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

taste_all = N*L + int((N - 1)*N/2)
ans = 0

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



print(ans)

Solution (Python):
N, L = map(int,input().split(' '))
l=list(range(L,N+L,1))
s = sum(l)
ans=-10000
for x in l:
    if abs(ans)>x:
        ans=x
print(s-ans)

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

Solution (Python):


N,L =  list(map(int,input().split()))
ringo=0
min=99999999
kekka = []

for i in range(N):
    ringo+=(i+L)
 
    if i+L>0:
        if min >i+L:
            min = i+L
    elif i+L<0:
        if 0 <abs(i+L):
            min = i+L
    elif i+L == 0:
        min = 0
        

print(ringo-min)

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

Solution (Python):
N, L = list(map(int, input().split()))
orig_taste = int(0.5 * N * (N + 1)) - N + L * N

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

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

Solution (Python):
a, b= map(int, input().split())
list=[]
list2=[]
sum=0
for n in range(a):
    list.append(n+b)
for n in range(a):
    list2.append(n+b)

if list.count(0)==1:
    for w in list:
        sum += w
    print(sum)
else:
    if list[len(list)-1] > 0:
        for w in list:
            sum += w
        print(sum-list[0])
    else:
        for w in list:
            sum += w
        print(sum-list[len(list)-1])

Solution (Python):
import numpy as np

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

tastes = np.arange(N) + L
total_taste = tastes.sum()

tastes_wo_ith_apple = total_taste - tastes
abs_tastes = np.abs(total_taste - tastes_wo_ith_apple)

print(tastes_wo_ith_apple[abs_tastes.argmin()])

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


for i in range(n):
    s.append(i+l)
a = sum(s)
m=0
c = abs(s[0])
for i in range(n):
    if c > abs(s[i]):
        c = abs(s[i])
        m = i
        

print(a-s[m])

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

if __name__ == "__main__":
    main()

Solution (Python):
N,L = map(int,input().split())
azi = [L+i-1 for i in range(1,N+1)]
b = sum(azi)
zero_count = 0
for i in range(N):
    if azi[i] == 0:
        print(b)
        zero_count = 1
        break

if zero_count == 0:
    if b<0:
        print(b-azi[N-1])
    else:
        print(b-azi[0])

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

original_apple_pie = 0
li = []
mi = 10e9
for i in range(N):
    tmp = L + i 
    li.append(tmp)
    original_apple_pie += tmp
    if mi > abs(tmp):
        mi = abs(tmp)
        ans = tmp

if original_apple_pie<0 and ans < 0:
    print(original_apple_pie-ans)
else:
    print(original_apple_pie-ans)

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

tastes = [l + i - 1 for i in range(1, n + 1)]
sum_tastes = sum(tastes)
sum_tastes_eat = [sum_tastes - tastes[i] for i in range(n)]
dif_tastes = [abs(sum_tastes - x) for x in sum_tastes_eat]

idx = dif_tastes.index(min(dif_tastes))
print(sum_tastes_eat[idx])

Solution (Python):

inputData = input().split()
N = int(inputData[0])
L = int(inputData[1])


aji_min = L + 1 -1
aji_max = L + N -1
if aji_max <= 0:
    print(sum(range(aji_min, aji_max - 1 + 1)))
    exit()
if aji_min >= 0:
    print(sum(range(aji_min + 1, aji_max + 1)))
    exit()
print(sum(range(aji_min, aji_max + 1)))

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

apple=[int(x+1) for x in range(int(a))]
taste=[int(int(b)+x+1-1) for x in range(int(a))]

if 0 in taste:
    taste.pop(taste.index(0))
    print(sum(taste))
elif taste[0]<0:
    taste.pop(-1)
    print(sum(taste))
else:
    taste.pop(0)
    print(sum(taste))

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

apple=[]

for num in range(1,N+1):
  apple.append(L + num -1)

taberu = min(map(abs,apple))

if taberu > max(apple):
  print(sum(apple)+taberu)
else:
  print(sum(apple)-taberu)

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

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

first = L
end = N + L -1
 

if first>=0:
    print((first+1 + end)*(N-1)//2)
elif (first<=0 and end>=0):
    print((first+end)*N//2)
else:
    print((first + end -1)*(N-1)//2)

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

apple1 = float('inf')
apple2 = -float('inf')
flag = 0
for i in taste:
    if i == 0:
        apple = i
        flag = 0
        break
    elif (apple2 < i < 0):
        apple2 = i
        flag = 1
    elif (0 < i < apple1):
        apple1 = i
        flag = 2
        
if flag == 1:
    pie = (sum(taste) - apple2)
elif flag == 2:
    pie = (sum(taste) - apple1)
else:
    pie = (sum(taste) - apple)
    
print(pie)

Solution (Python):
N,L=map(int,input().split())
tabenai = [(L+_-1) for _ in range(1,N+1)]
abs_tabenai = [abs(L+_-1) for _ in range(1,N+1)]
min_index = abs_tabenai.index(min(abs_tabenai))
ans = sum(tabenai)-tabenai[min_index]
print(ans)

Solution (Python):
N, L = map(int,input().split())
result = 0
Min = L
Max = L + N - 1
flg = 0
for i in range(1,N+1):
  x = L + i - 1
  if x == 0:
    flg = 1
  result = result + x

if flg == 1:
  print(result)
else:
  if Min < 0:
    print(result-Max)
  else:
    print(result-Min)

Solution (Python):
N, L = (int(x) for x in input().split())
def func(i):
    return (N*(2*L+N-1)//2) - (L+i-1)

if -L+1 <= 1:
    print(func(1))
elif 1 <= -L+1 and -L+1 <= N:
    print(func(-L+1))
else:
    print(func(N))

Solution (Python):
import numpy as np

a,b = map(int, input().split())
s_max = b + a -1
s_min = b 
ans = 0 

if s_min >= 0 and s_max >= 0:
    for i in range(s_min + 1,s_max+1):
        ans += i
           
    print (ans)
elif s_min < 0 and s_max > 0:
    for i in range(s_min,s_max+1):
        ans += i
           
    print (ans)
else:
    for i in range(s_min,s_max):
        ans += i
           
    print (ans)

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

al = [i + l - 1 for i in range(1, n+1)]
res=100000
ans=0
total = sum(al)

for i in range(0, len(al)):
    if abs(total - (total - al[i])) < res:
        res = abs(total - (total - al[i]))
        ans = total - al[i]
        
        
print(ans)

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

sum = n * (l - 1) + (n * (n + 1)) / 2.0

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

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

aaa = list(range(L, N + L))
n = sum(aaa)
if n == 0:
    print(0)
elif n < 0:
    print(n - max(aaa))
else:
    print(n - max(0,min(aaa)))

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

apple_azi = [L + (x + 1) - 1 for x in range(N)]

original_pai = sum(apple_azi)

test = []
for i in apple_azi:
    
    test.append(abs(original_pai - (original_pai - i)))

tabeta_azi = min(test)

if original_pai >= 0:
    print(original_pai - tabeta_azi)
else:
    print(original_pai + tabeta_azi)

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

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

Solution (Python):
N, L = map(int, input().split(" "))
max = 0
min = L

for i in range(N):
    t = L + i
    if t**2 < min**2:
        min = t
    max += t

print(max-min)

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

Solution (Python):


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

ringo=[]

for i in range(n):
	ringo.append(l+i)
min = abs(ringo[0])
min_num = 0
for i in range(len(ringo)):
	if min > abs(ringo[i]):
		min = abs(ringo[i])
		min_num = i
out = 0
for i in range(len(ringo)):
	if i != min_num:
		out = out + ringo[i]
print(out)

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

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

al = int((L-1)*N + 0.5*N*(N+1))
if L >= 0:
    tmp = L
elif L < 0 and abs(N) > abs(L):
    tmp = 0
else:
    tmp = L + N - 1

print(al -tmp)

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

all_pie = num * l + sum - num
if l >= 0:
    print(all_pie - l)
elif abs(l) <= num -1:
    print(all_pie)
else:
  print(all_pie - (l + num - 1))

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

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

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

p = []
pi = []
pi_s = []


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

all_t = sum(p)

for i in range(N):
    pi.append(all_t - p[i])
    pi_s.append(abs(all_t - pi[i]))


min_abs = pi_s[0]
ans = 0

for i in range(1,N):
    if min_abs > pi_s[i]:
        min_abs = pi_s[i]
        ans = i



print(pi[ans])

Solution (Python):
import numpy as np
N, L = map(int, input().split())
zenbu=[]
for i in range(N):
  aj=L+i
  zenbu.append(aj)
aji=sum(zenbu)
zenbu_abs=np.abs(zenbu)
a=zenbu_abs.argmin()


eat=zenbu[a]
kotae=aji-eat
print(kotae)

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

taste       = 0
total_taste = 0
tastes = []
for i in range(1, N+1):
    taste = (L + i - 1) 
    total_taste += taste
    tastes.append(taste)

diff_tastes      = {}
for i in range(0, len(tastes)):
    diff_total_taste = 0
    for j in range(0, len(tastes)):
        if(i != j):
            diff_total_taste += tastes[j]
    diff = abs(total_taste - diff_total_taste)
    diff_tastes[diff_total_taste] = diff

print(min(diff_tastes, key=diff_tastes.get))

Solution (Python):
N,L = [int(i) for i in input().split()] 
bi=None
if 2<=1-L and 1-L<=N:
    bi =1-L
elif 1-L>=N:
    bi = N
elif 2>=1-L:
    bi =1
ajis = [L+i for i in range (N)]
org_sum = sum(ajis)
ans = org_sum -(L+bi-1)
print(ans)

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

Solution (Python):
apples =str(input())
apples_list = apples.split(" ")
N = int(apples_list[0])
L = int(apples_list[-1])
pai_values = []
 
for i in range(1,N+1):
    pai_value = i + L -1
    pai_values.append(pai_value)
    
min_pai = abs(pai_values[0])
target_number = 0
 
for j in range(N):
    if min_pai > abs(pai_values[j]):
        min_pai = abs(pai_values[j])
        target_number = j
        
pai_values.pop(target_number)
 
answer = sum(pai_values)
 
print(int(answer))

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

def eat():
    if L > 0:
        return L
    elif L > (-N):
        return 0
    else:
        return L + N - 1

print( (2*L + N - 1) * N // 2 - eat() )

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

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

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

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

if (l<0):
  if l>=(-n+1):
  	print(flavor)
  elif l<(-n+1):
    print(flavor-(l+n-1))
    

else:
  print(flavor-l)

Solution (Python):
'''n,l=map(int,input().split( ))
f=[0]*(n+1)
for i in range(1,n+1):
	f[i]=l+i-1
p=[0]*(n+1)
s=[0]*(n+1)
sum=0
for i in range(1,n+1):
	p[i]=sum+f[i]
	sum=p[i]
sum=0
for i in range(n,0,-1):
	s[i]=sum+f[i]
	sum=s[i]
ans=10**9+7
total=s[1]
for i in range(1,n+1):
	if i==n:
		temp=total-f[i]
		if temp<ans:
			ans=temp
	else:
		temp=total-(p[i-1]+s[i+1])
		if temp<ans:
			ans=temp
print(ans)
print(total-ans)

'''
n,l=map(int,input().split( ))
f=[0]*(n+1)
for i in range(1,n+1):
	f[i]=l+i-1
total=sum(f)
x=10**9+7
for i in range(1,n+1):
	r=total-f[i]
	c=abs(total-r)
	if c<x:
		ans=r
		x=c
print(ans)

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

for i in range(N):
    aji = L + i+1 - 1
    aji_list.append(aji)
    aji_list_abs.append(abs(aji))

aji_list = sorted(aji_list)
min_abs_aji = min(aji_list_abs)


if not min_abs_aji in aji_list:
    min_abs_aji = min_abs_aji * -1

aji_list.remove(min_abs_aji)

print(sum(aji_list))

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

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

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

min_apple = L

total_taste = 0

for i in range(N):
    taste = L + i
    if abs(0 - min_apple) > abs(0 - taste):
        min_apple = taste

    total_taste += taste

print(total_taste - min_apple)

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

Solution (Python):


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

a = []
b = []

for i in range(1, N+1):
    a.append(L+i-1)
    b.append(abs(L+i-1))





print(sum(a) - a[b.index(min(b))])

Solution (Python):
class BiteEat:
    def __init__(self):
        self.N, self.L = map(int, input().split())

    def __taste(self, i):
        return self.L + i - 1

    def cal(self):
        first = self.__taste(1)
        last = self.__taste(self.N)
        total = (first + last) * self.N // 2

        if first >= 0:
            print(total - first)
        elif last <= 0:
            print(total - last)
        else:
            print(total)


biteEat = BiteEat()
biteEat.cal()

Solution (Python):
n, l = map(int, input().split())
aji = []
for i in range(1, n+1):
    aji.append(l + i - 1)
aji_sum = sum(aji)
sa = 1000000007
for i in range(n):
    if abs(sum(aji[:i]) + sum(aji[i+1:]) - aji_sum) <= sa:
        sa = abs(sum(aji[:i]) + sum(aji[i+1:]) - aji_sum)
        ans = sum(aji[:i]) + sum(aji[i+1:])
print(ans)

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

azi = [v for v in range(l,l+n,1)]
moto = sum(azi)

m = float("inf")

for i in azi:
  if abs(m) > abs(i):
    m = i

print(moto - m)

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

taste_list = []
for i in range(num_apple):
  taste_list.append(num + i)

def func_abs(n):
    return abs(n)
  
min_abs = min(taste_list, key=func_abs)
taste_list.remove(min_abs)
print(sum(taste_list))

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

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

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

Solution (Python):
import numpy as np
x, y = map(int, input().split())
A = []

for i in range(x):
    A.append(y)
    y += 1

B = np.abs(A)

we = min(B)
if we not in A:
    we = - + we
    A.remove(we)
else:
    A.remove(we)

cnt = 0
for i in A:
    cnt += i

print(cnt)

Solution (Python):
N, L = map(int,input().split())
lisu = [L+i-1 for i in range(1,N+1)]
abs_l = [abs(i) for i in lisu]
mii = min(abs_l)
auu = sum(lisu)
ans = auu - lisu[abs_l.index(mii)]
print(ans)

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

pies = [l+i-1 for i in range(1,n+1)]
pie_plan = sum(pies)
pie_real = 0
diff_plan_real = float("inf")
for i in range(1,n+1):
    pie_provisonal = sum([l+j-1 for j in range(1,n+1) if j != i])
    if abs(pie_plan - pie_provisonal) < diff_plan_real:
        diff_plan_real = abs(pie_plan - pie_provisonal)
        pie_real = pie_provisonal
    
print(pie_real)

Solution (Python):




def main():
    N, L = map(int, input().split())

    mn = 2 * 10 ** 9
    ans = -1
    x = 0
    for i in range(N):
        x += L + i

    for i in range(N):
        cur = 0
        for j in range(N):
            if i == j:
                continue
            cur += L + j
        if abs(x-cur) < mn:
            mn = abs(x-cur)
            ans = cur

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
a = input().split()

b = int(a[0])
c = int(a[1])
d = []
for i in range(b):
    d.append(c + i)

if d.count(0) == 1:
    d.remove(0)
elif c < 0:
    del d[-1]
elif c > 0:
    del d[0]

e = sum(d)
print(e)

Solution (Python):
N,L=(int(i) for i in input().split())
x=0
y=[]
z=[]
zy=[]
for i in range(1,N+1):

    x+=i+L-1
    y.append(i+L-1)
    z.append(i+L-1)


for i in y:

    z.remove(i)

    zy.append(sum(z))


    z.append(i)

sa=x-zy[0]



for i in zy:
    if((x-i)<abs(sa)):
        sa=x-i
num=zy.index(x-sa)
print(zy[num])

Solution (Python):
from sys import stdin

n,l = [int(x) for x in stdin.readline().rstrip().split()]
aji_arr = []
total = 0

for i in range(1,n+1):
    aji = l+i-1
    total += aji
    
    if(i == 1):
        aji_min = abs(aji)
        del_aji = aji
    elif(aji_min >= abs(aji)):
        aji_min = abs(aji)
        del_aji = aji
total = total - del_aji
print(total)

Solution (Python):

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


all_taste = 0

for i in range(1, n+1):
    
    tmp = l + i - 1
    all_taste = all_taste + tmp


act_taste = 0


eat_apple = l + 1 - 1
for i in range(1, n+1):
    cmp_apple = l + i - 1
    
    if abs(cmp_apple) <= abs(eat_apple):
        eat_apple = cmp_apple
        act_taste = all_taste - eat_apple


print(act_taste)

Solution (Python):
a, b = map(int, input().split())
sum = 0
min = 100
minabs = 100
for i in range(a):
    c = b + i
    sum += c
    if minabs > abs(c):
        minabs = abs(c)
        min = c
print(sum - min)

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

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

aas=sum(a)

ans=(10**10)
for i in range(n):
    aji=aas-a[i]
    if ans>abs(aas-aji):
        ans=abs(aas-aji)
        ans2=aji
print(ans2)

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

eatApple = -101

i = 1
sumApple = 0
while i <= N:
    now = L + i - 1
    if abs(now) < abs(eatApple):
        eatApple = now
    sumApple += now
    i += 1

print(sumApple - eatApple)

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

all_t = sum(taste)

save = copy.copy(taste)
azi = []

for i in range(0,n):
    del taste[i]
    azi.append(abs(all_t - sum(taste)))
    taste  = copy.copy(save)

a = azi.index(min(azi))
del taste[a]
print(sum(taste))

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

apples = [0] * N

ate_apple = 100
apple_pie = 0

for i in range(N):
  apples[i] = L + i
  apple_pie += apples[i]
  if abs(ate_apple) > abs(apples[i]):
    ate_apple = apples[i]

print(apple_pie - ate_apple)

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

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


pie = 0
ans = 10**9

for i in range(1,N+1):
  pie += L + i - 1
  
if L >= 1:
  ans = pie - L
elif abs(L-1) <= N:
  ans = pie
else:
  ans = pie - (L+N-1)
print(ans)

Solution (Python):
str = input().split(" ")
n = int(str[0])
l = int(str[1])
aji = []
for i in range(1, n+1):
    aji.append(l+ i-1)
    
sa = sum(aji)
mina = 1000
min_index = None
for i in range(0, n):
    tmp = aji.copy()
    tmp.pop(i)
    dif = abs(sa - sum(tmp))
    if mina > dif:
        mina = dif
        min_index = i
        


aji.pop(min_index)

print(sum(aji))

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

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

Solution (Python):

def main():
    N,L = map(int,input().split())
    taste = []
    ABS = []
    for i in range(N):
        taste.append(L+i+1-1)
        
    for j in taste:
        ABS.append(abs(j))
        
    taste.pop(ABS.index(min(ABS)))
    print(sum(taste))

if __name__ == '__main__':
    main()

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

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

Solution (Python):
import sys,collections,math,random;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())

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

Solution (Python):
import copy

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

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

pie_taste = sum(apple_taste)

min_diff = 100000
for i in range(N):
    ap = copy.deepcopy(apple_taste)
    ap[i] = 0

    pie_taste2 = sum(ap)
    diff = abs(pie_taste - pie_taste2)

    if diff < min_diff:
        min_diff = diff
        min_index = i


apple_taste[min_index] = 0

print(sum(apple_taste))

Solution (Python):
N,L=map(int,input().split())
sum1=0
sum2=0
ans=0
min=100000000000000000000000000000
result=0

taste_list=[1]*N
for i in range(N):
    taste_list[i]=(L+i)
    

for i in range(N):
    sum1=sum(taste_list)
    sum2=sum(taste_list[:i])+sum(taste_list[i+1:])
    ans=abs(sum1-sum2)
    if min>ans:
        min=ans
        result=sum2
        

print(result)

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

rng = list(range(l, l+n))
min_abs = 400
val = 0
for r in rng:
  if min_abs > abs(r):
    min_abs = abs(r)
    val = r

print(sum(rng) - val)

Solution (Python):
import numpy as np
a = input()
n, l = [int(i) for i in a.split(" ")]
apples = np.array([i for i in range(n)])
aji = apples + l
abss = [np.abs(aji[apples != i].sum() - aji.sum()) for i in range(n)]
i = abss.index(np.min(abss))
print(aji[apples != i].sum())

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

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

sum = 0

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

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

else:
    for i in range(0, N-1):
        sum += int(i) + L

print(sum)

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

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

if 0 in arr:
    arr.remove(0)
else:
    if L + N <= 0:
        arr.sort(reverse=True) 
    arr.pop(0)

print(sum(arr))

Solution (Python):
import numpy as np

n,l = [int(x) for x in input().split()] 
x = np.arange(l,l+n)
y = np.abs(x)
x = np.delete(x, np.argmin(y))
print(np.sum(x))

Solution (Python):
a,b = map(int,input().split())
num=b
s=0
minA = 500
store= []
ans = []
final = []
c=-1
for i in range(a):
    store.append(num);
    s+=num
    num+=1
for v in store:
    cur = s-v
    final.append([abs(s-cur),cur])
final.sort()
print(final[0][1])

Solution (Python):
import numpy as np

n, l = map(int, input().split())
a = list(l + i - 1 for i in range(1, n + 1))
idx = np.abs(np.asarray(a) - 0).argmin()

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

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

Solution (Python):
import numpy as np
N,L = map(int, input().split())
taste=np.arange(N)+1 +L-1

if 0 in taste:
    print(taste.sum())
else:
    if taste[-1]>0:
        print(taste[1:].sum())
    else:
        print(taste[:-1].sum())

Solution (Python):
N, L = map(int, input().split())
min = abs(L) + N
ans = 0
for n in range(1, N+1):
    tmp = L+n-1
    ans += tmp
    if abs(min) > abs(tmp):
        min = tmp

print(ans-min)

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

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

flag=0
ans = abs(total-(total-ls[0]))
for i in range(n):
  tst = total - ls[i]
  dif = abs(total-tst)
  if dif<ans:
    flag = i
    ans = dif
print(total-ls[flag])

Solution (Python):
n, l = list(map(int, input().split()))
s = 0
r = []
for t in range(n):
    s += l
    r.append(abs(l))
    l += 1
m = min(r)
if r[0] > r[-1]:
    print(s + m)
else:
    print(s - m)

Solution (Python):






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





taste = list(range(L, N+L))





choice_index = list(map(abs, taste)).index(min(list(map(abs, taste))))
del taste[choice_index]
print(sum(taste))

Solution (Python):

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

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


worst = L
for n in range(N):
  if abs(worst)>abs(L+n):
    worst=L+n
worst=worst-L+1

worst_score=L+worst-1
print(sum_apple-worst_score)

Solution (Python):
nl = input().split(" ");
n = int(nl[0]);
l = int(nl[1]);
taste = [0]*n;
eat = 100;
j = 0;
for i in range(n) :
	taste[i] = l + i;
	if abs(l + i) < eat :
		eat = abs(l+i);
		j = i;
print(sum(taste)-taste[j]);

Solution (Python):

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

ringo = []
abs_list = []

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

minus = True

minabs = 100000

for i in ringo:
    if abs(i) < minabs :
        minabs = abs(i)
        if i > 0 :
            minus = False

ans = sum(ringo)

if minus == True :
    print(ans + minabs)
else:
    print(ans - minabs)

Solution (Python):
import numpy as np

if __name__ == '__main__':
    n, l = map(int, input().split())
    apples = np.arange(start=1, stop=n + 1, step=1)
    apples_taste = apples + l - 1
    apples_taste_abs = np.abs(apples_taste)
    index_can_eat_apple = apples_taste_abs.argmin()
    nokori_apples = np.delete(apples_taste, index_can_eat_apple)
    print(np.sum(nokori_apples))

Solution (Python):
N , X =map(int,input().split())
sums = []
i = X
result =[]
a = []
for i in range(N):
    sums.append(i+X)
for j in range(N):
    a.append(abs(sums[j]))

if sum(sums) ==abs(sum(sums)):
    print(sum(sums) - min(a))
else :
    print(sum(sums) + min(a))