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
input = sys.stdin.readline
n,l = map(int,input().split())
if l >= 1:
  print((l+l+n)*(n-1)//2)
elif l+n<=1:
  print((l+l+n-2)*(n-1)//2)
else:
  print((l+l+n-1)*n//2)

Solution (Python):
N,L=map(int,input().split())
aji=[]
for i in range(N):
    aji.append(L+i)
a=float('inf')
for i in aji:
    if abs(i) == min(abs(a),abs(i)):
        a=i
print(sum(aji)-a)

Solution (Python):
N,L=map(int,input().split())
apple_taste=[0]*N
eat_apple=0
for i in range(0,N):
    apple_taste[i]+=L+i
    if abs(apple_taste[eat_apple])>abs(apple_taste[i]):
        eat_apple=i

print(sum(apple_taste)-apple_taste[eat_apple])

Solution (Python):
n, l = map(int, input().split())
ans = 0
eat = 1+l-1

for i in range(1, n+1):
  apple_taste = i+l-1
  ans += apple_taste
  if abs(eat) > abs(apple_taste):
    eat = apple_taste

print(ans-eat)

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

Solution (Python):
n, l = map(int, input().split())
a = { l+i for i in range(n) }
if 0 in a:
  print(sum(a))
else:
  if min(a) > 0:
    print(sum(a)-min(a))
  else:
    print(sum(a)-max(a))

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

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

Solution (Python):
def main():
    n,l = [int(x) for x in input().split()]
    array = [int(x) for x in range(l,l+n)]

    array_abs = [abs(x) for x in array]
    minimum_val = min(array_abs)
    min_index = array_abs.index(minimum_val)

    array[min_index] = 0
    ans = sum(array)
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
N,L = map(int,input().split())
import math
T = []
for i in range(N):
  T.append(L+i)
cnt = 0
mcnt = sum(T)
k = 1000000
for i in range(0,N):
  if abs(T[i])<k:
    mcnt = sum(T)-T[i]
    cnt = i+1
    k=abs(T[i])
print(mcnt)

Solution (Python):
N,L=map(int,input().split())
d=list(range(1,N+1))
s=[]
a=1000
b=0

for i in range(N):
  s.append(L+i)
for j in range(N):
  if a > abs(s[j]):
    a=abs(s[j])
    b=s[j]
print(sum(s)-b)

Solution (Python):
N, L = map(int,input().split())
Sum = 0
S = 500
ans = 0
for i in range(1,N+1):
  Sum += L + i - 1
  if abs(L + i - 1) < abs(S):
    S = L + i - 1
print(Sum - S)

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

Aji = [L+i-1 for i in range(1,N+1)]
EAT = abs(Aji[0])

for i in range(N):
    if abs(EAT) > abs(Aji[i]):
        EAT = Aji[i]
        
ans = sum(Aji) - EAT

print(ans)

Solution (Python):
N, L = map(int, input().split())
sumi = (N * L + ((N-1) * N)//2)
mini = 10**10
ans = sumi
for idx in range(N):
	if(mini > abs(L+idx)):
		mini = abs(L+idx)
		ans = sumi - (L+idx)
print(ans)

Solution (Python):
N, L = map(int, input().split())
A = [L + i for i in range(N)]
sum_A = sum(A)
ans = []
for i in range(N):
    B = A.copy()
    del B[i]
    ans.append(sum(B))
c = [abs(ans[i] - sum_A) for i in range(N)]
index = c.index(min(c))
print(ans[index])

Solution (Python):
import numpy as np
n, l = map(int, input().split())
taste = [l + i for i in range(n)]
tasteabs = np.array(list(map(abs, taste)))
taste.pop(np.argmin(tasteabs))
print(sum(taste))

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

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

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

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

taste = []
j = 500
k = 0
adr = 0
for i in range(l,n+l,1):
    taste.append(i)
    j = min(j,abs(i))
    if j == abs(i):
        adr = k
    k += 1

res = sum(taste) - taste[adr]
print(res)

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

m = 10 ** 4
c = m
ans = 0

for i in range(L, N+L):
    if m > abs(i):
        m = abs(i)
        c = i

    ans += i


print(ans - c)

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

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

if __name__ == '__main__':
    solve()

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

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

List=list(map(abs,ans))

ans.pop(List.index(min(List)))

print(sum(ans))

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

T=[]
sum_t = 0

for n in range(N):
    taste = L + (n+1) -1
    sum_t += taste
    T.append(abs(taste))

m = T.index(min(T))

sum_t -= L + (m+1) -1
print(sum_t)

Solution (Python):

N, L = list(map(int,input().split()))
a = L
b = L + N-1
taste = 0
for i in range(N):
    taste += L + i
if b < 0:
    print(taste - b)
elif a <= 0 and b >= 0:
    print(taste - 0)
elif a > 0:
    print(taste-a)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

x = min(range(L,L+N),key=abs)
answer = sum(range(L,L+N)) - x
print(answer)

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


pie = [l + i for i in range(n)]
pie_abs = [abs(pie[j]) for j in range(n)]

pie.pop(pie_abs.index(min(pie_abs)))

print(sum(pie))

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

taste = 0
min = 300
for i in range(N):
	t = L+i
	taste += t
	if t*t < min*min:
		min = t
taste -= min

print(taste)

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

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

t_sum = 0
t_min = 1000
t_min_index = 1000
for i in range(1, n+1):
    if t_min != min(t_min, abs(l+i-1)):
        t_min = min(t_min, abs(l+i-1))
        t_min_index = i
    t_sum += l+i-1

t_min = l + t_min_index - 1
print(t_sum - t_min)

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

tot = 0
apple = []
mn, pl = 10**10, 0

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

for i in range(n):
    if abs(apple[i]) < mn:
        mn = abs(apple[i])
        pl = i

print(tot - apple[pl])

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

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

for j in re:
  re_abs.append(abs(j))

re.pop(re_abs.index(min(re_abs)))
print(sum(re))

Solution (Python):
n,l=map(int,input().split())
a=list(map(lambda x:l+x-1,list(range(1,n+1))))
a_abs=list(map(lambda x:abs(x),a))
print(sum(a)-a[a_abs.index(min(list(map(lambda x:abs(x),a))))])

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

Solution (Python):
def solve():
    N, L = map(int, input().split())
    ans = 0
    biting_apple = 200

    for i in range(N):
        ans += L+i
        if abs(L+i) < abs(biting_apple):
            biting_apple = L+i
    
    ans -= biting_apple

    print(ans)

solve()

Solution (Python):
def solve():
    N,L = map(int, input().split())
    a = [abs(L+i) for i in range(N)]
    b = [L+i for i in range(N)]
    [a.index(min(a))]
    print(L*N+sum(range(N))-b[a.index(min(a))])
    

if __name__ == '__main__':
    solve()

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

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

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

print(ans)

Solution (Python):
a, b = map(int, input().split())
L1 = []
L2 = []
for i in range(1,a+1):
  L1.append(b+i-1)
  L2.append(abs(b+i-1))
del L1[L2.index(min(L2))]
print(sum(L1))

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

s = list(l+i-1 for i in range(n+1))
a = list(sum - int(abs(s[j])) for j in range(1,n+1))

if max(a) > 0:
        print(int(max(a)))
elif max(a)<0:
        print(int(sum - max(s)))
else:
        print(int(sum))

Solution (Python):
N, L = map(int, input().split())
apple = [i+L for i in range(N)]
sum_apple = (sum(apple))
sa = float("inf")

for i in range(N):
    apple_pie = apple[:i] + apple[i+1:]
    count = 0
    for j in range(len(apple_pie)):
        count += apple_pie[j]
        if sa > abs(sum_apple - count):
            sa = abs(sum_apple - count)
            ans = count
print(ans)

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

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

dif=101
for i in range(len(tastes)):
    tmp=tastes[:]
    tmp.pop(i)
    if dif > abs(applepi-sum(tmp)):
        dif = abs(applepi-sum(tmp))
        apples=tmp[:]

print(applepi-(applepi-sum(apples)))

Solution (Python):
N, L = map(int, 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):
import numpy as np
N,L = map(int,input().split())
apple = np.array(range(N)) + 1
taste = apple + L - 1
taste_applepie = sum(taste)
if L <= 0 and abs(N) > abs(L):
    print(taste_applepie)
elif L > 0:
    print(taste_applepie - L)
else:
    print(taste_applepie - (N+L-1))

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

taste = []

for i in range(0,N):
	taste.append(L + i)
		
if 0 in taste:
	print(sum(taste))
	
else:
	if L > 0:
		print(sum(taste) - taste[0])
	elif L < 0:
		print(sum(taste) - taste[N-1])

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

taste_a = taste[absTaste.index(min(absTaste))] 
print(sum(taste) - taste_a)

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


Apple_taste = [L+i for i in range(N)]
eaten_Apple = min(Apple_taste, key=abs)
Apple_taste.remove(eaten_Apple)
print(sum(Apple_taste))

Solution (Python):
import copy

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

n_L = list(range(n))
a_L = list(map(lambda x:l+x,n_L))

a_L.append(0)

allsum = sum(a_L)

result_L = []

diff = abs(allsum-sum(a_L[1:]))

for val in range(n):
    b_L = copy.copy(a_L)
    b_L.pop(val)
    temp_sum = sum(b_L)

    if abs(allsum-temp_sum) <= diff:
        result = temp_sum
    diff = abs(allsum-temp_sum)

print(result)

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

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

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    n, l = list(map(int, input().rstrip('\n').split()))
    ls = []
    t = 0
    for i in range(n):
        ls.append([abs(l + i), l + i])
        t += (l + i)
    ls.sort()
    print(t - ls[0][1])


if __name__ == '__main__':
    slove()

Solution (Python):
n, l = map(int, input().split())
ret = 0
eat = [1e9, 0]
for i in range(1, n+1):
    ret += i
    if abs(i + l - 1) < eat[0]:
        eat = [abs(i + l - 1), i + l - 1]
ret += ((l - 1) * n)
print(ret - eat[1])

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

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


def a(x):
    return abs(l + x)


c = min(list(range(n)), key=a)
j = 0
for i in range(n):
    if i != c:
        j += l + i
print(j)

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))
idx=B.index(min(B))
print(sum(A)-A[idx])

Solution (Python):
n,l=map(int,input().split())
aji=[]
for i in range(n):
    aji.append(l+i)
aji_abs=[]
for i in aji:
    aji_abs.append(abs(i))
e=aji_abs.index(min(aji_abs))

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

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

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

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

print(sum(apples[1:]))

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

Solution (Python):
import math
n, l = map(int, input().split())
fabs_lis = []
true_lis = []
for i in range(n):
    fabs_lis.append(math.fabs(i+l))
    true_lis.append(i+l)
index = fabs_lis.index(min(fabs_lis))
print(sum(true_lis)-true_lis[index])

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

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

absolutes = []

for v in taste:
    if v >= 0:
        absolutes.append(v)
    else:
        absolutes.append(-v)

min = min(absolutes)
index = absolutes.index(min)
w = taste[index]
sum = sum(taste)-w

print(sum)

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

aji = []
aji_abs = []
total = 0
for i in range(n):
  a = l + (i + 1) - 1
  aji.append(a)
  aji_abs.append(abs(a))
  total += a

print(total - aji[aji_abs.index(min(aji_abs))])

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

Solution (Python):

import sys


def solve(N: int, L: int):
    ab = []
    sum_teste = 0
    for i in range(N):
        taste = L + i
        sum_teste += taste
        ab.append(abs(taste))
    if sum_teste > 0:
        result = sum_teste - min(ab)
    else:
        result = sum_teste + min(ab)
    print(result)
    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_ = (int(i) for i in input().split())
l = list(range(l_, l_+n))
if all(i > 0 for i in l):
  print(sum(l) - min(l))
elif all(i < 0 for i in l):
  print(sum(l) - max(l))
else:
  print(sum(l))

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

Solution (Python):
import sys

input = sys.stdin.readline


def main():
    N, L = [int(i) for i in input().split()]
    aji = [L + i for i in range(N)]
    print(sum(aji) - min(aji, key=abs))


if __name__ == "__main__":
    main()

Solution (Python):
import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

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

if __name__ == '__main__':
    main()

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

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

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

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

a = [l + i for i in range(n)]
print(sum(a) - min(a, key=abs))

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

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

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

Solution (Python):
N,L= list(map(int, input().split()))
li=[L+i for i in range(N)]
mi=100000
ma=-1000000000
for i in li:
    if i>=0:
        mi=min(mi,i)
    else:
        ma=max(ma,i)
if abs(ma)>mi:
    print(sum(li)-mi)
else:
    print(sum(li)-ma)

Solution (Python):
N, L = map(int, input().split())
a = []
t = 10**9
ti = 0
for i in range(N):
  if abs(L + i) < t:
    t = abs(L + i)
    ti = i
  a.append(L + i)
a[ti] = 0
print(sum(a))

Solution (Python):
n, l = [int(i) for i in input().split()]
ntaste = sum([l + i for i in range(n)])
ntastes = [ntaste - (l + i) for i in range(n)]
cand = ntastes[0]
diff = abs(ntaste - cand)
for i in range(n):
	if abs(ntaste - ntastes[i]) < diff:
		diff = abs(ntaste - ntastes[i])
		cand = ntastes[i]
print(cand)

Solution (Python):


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

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

print ans

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


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


if __name__ == '__main__':
    main()

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

lis_taste = [L + (i + 1) - 1 for i in range(N)]
lis_abs = [abs(i) for i in lis_taste]
lis_taste.pop(lis_abs.index(min(lis_abs)))
print(sum(lis_taste))

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

if 0 in list1:
    del list1[list1.index(0)]
elif min(list1) > 0:
    del list1[list1.index(min(list1))]
else:
    del list1[list1.index(max(list1))]
print(sum(list1))

Solution (Python):
n, l = map(int, input().split())
i = 0
line = []
while i < n:
    line.append(abs(l+i))
    i += 1
eatone = line.index(min(line))
print((n*(n-1)//2)+(n-1)*l-eatone)

Solution (Python):
def main():

    N, L = map(int, input().split())
    total = N * L + int(N * (N + 1) / 2) - N
    mylst = []
    for i in range(1, N + 1):
        taste = L + i - 1
        mylst.append(taste)
        mylst.sort()
        if taste == 0:
            print(total)
            exit()
    if mylst[0] < 0:
        mn = max(mylst)
        print(total - mn)
    else:
        mn = min(mylst)
        print(total - mn)

    
if __name__ == "__main__":
    main()

Solution (Python):
import numpy as np

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

T=[]
for i in range(N):
    T.append(L+i)
    
T=np.array(T)
U=abs(T)

print(sum(T)-T[U.argmin()])

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

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

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

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

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

if 0 in aji_list:
    aji_list.remove(0)
elif min(aji_list) > 0:
    aji_list.remove(min(aji_list))
else:
    aji_list.remove(max(aji_list))
print(sum(aji_list))

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

Solution (Python):
N,L = map(int,input().split())
min_abs = float('inf')
Taste = []
for i in range(N):
  taste = L+(i+1)-1
  if(min_abs > taste):
     min_abs = abs(taste)
     min_abs_index = i
  Taste.append(taste)

Taste.pop(min_abs_index)
ans = sum(Taste)
print(ans)

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

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

taste = [_ for _ in range(L,L+N)]
tmp = float("inf")

for t in taste:
  if abs(tmp) > abs(t):
    tmp = t

print(sum(taste) - tmp)

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

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

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

taste = []

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


taste = sorted(taste, key=abs, reverse=True)
taste.pop()

print(sum(taste))

Solution (Python):
import numpy as np


def getNearestValue(list, num):
    """
    概要: リストからある値に最も近い値を返却する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx
  
n,l = map(int, input().split())

a = (list(l + i -1 for i in range(1,n+1)))

print(sum(a) - a[getNearestValue(a, 0)])

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

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

Solution (Python):
import math
N, L = map(int,input().split())
min = 1000
ans = 0
A = [0] * N
for i in range(N):
    A[i] = L + (i+1) - 1
    ans += A[i]

for i in range(N):
    a = math.fabs(A[i])
    if a < min:
        min = a
        if A[i] < 0:
            judge = False
        else:
            judge = True
if judge:
    ans -= min
else:
    ans += min
print(int(ans))

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

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

taste = []
sum = 0

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



zero_near_apple = taste[0]

for i in range(0, n-1):
  if abs(taste[i]) > abs(taste[i+1]):
    zero_near_apple = taste[i+1]


print(sum - zero_near_apple)

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

taste = []
sum = 0

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



zero_apple = taste[0]

for i in range(0, n-1):
  if abs(taste[i]) > abs(taste[i+1]):
    zero_apple = taste[i+1]


print(sum - zero_apple)

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

Solution (Python):

import sys


def solve(N: int, L: int):

    taste = []
    taste_abs = []

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

    idx_delete = taste_abs.index(min(taste_abs))
    taste.pop(idx_delete)
    result = sum(taste)

    print(result)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  
    L = int(next(tokens))  
    solve(N, L)


if __name__ == "__main__":
    main()

Solution (Python):
N, L = map(int, input().split())
full = sum(range(1, N+1)) + N * (L - 1)
diff = 1000

for i in range(1, N+1):
    if abs(diff) > abs(L + i - 1):
        diff =  - (L + i - 1) 
print(full + diff)

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

sum = 0
min_val = 100000

for i in range(1,N+1):
  sum += L+i-1
  if abs(L+i-1) < abs(min_val):
    min_val = L+i-1
    
print(sum-min_val)

Solution (Python):
N,L = list(map(int,input().split()))
A = [0]*N

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

if A[0] > 0:
    for i in range(1,N):
        aji = aji + A[i]
elif A[N-1] < 0:
    for i in range(0,N-1):
        aji = aji + A[i]
else:
    for i in range(N):
        aji = aji + A[i]
        
print(aji)

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

ans = 0
s = N*L + N*(N-1)//2
dif = int(1e+9)
for i in range(N):
    tmp = 0
    for j in range(N):
        if j != i:
            tmp += L+j
    if abs(s-tmp) < dif:
        ans = tmp
        dif = abs(s-tmp)

print(ans)

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

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

pie_n = (n*l) + (n*(n+1)//2) - n
taste = []
diff = []

for i in range(n):
  taste.append(pie_n - (l+i))
  diff.append(abs(l+i))
  
print(taste[diff.index(min(diff))])

Solution (Python):
N, L = list(map(int, input().split()))
L_list = [L+i-1 for i in range(1, N+1)]
L_list.sort(key=lambda x: abs(x), reverse=True)
L_list.pop()
print(sum(L_list))

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

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

Solution (Python):
from sys import stdin

n,l = [int(x) for x in stdin.readline().rstrip().split()]
li = []
abss = []
for i in range(1,n+1):
    aji = l + i - 1
    li.append(aji)
    abss.append(abs(aji))
li.pop(abss.index(min(abss)))
print(sum(li))

Solution (Python):
s=list(input().split())
n=int(s[0])
l=int(s[1])
apple=[]
total=[]
for i in range(n):
  taste=l+(i+1)-1
  if taste<0:
    apple.append(taste*-1)
  else:
    apple.append(taste)
  total.append(taste)
total.pop(apple.index(min(apple)))
print(sum(total))

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

kind = [i + 1 for i in range( N )]
taste = [i + L for i in range( N )]
taste_abs = [abs(i + L) for i in range( N )]

cnt =0

for i in taste:
    if i<0:
        cnt +=1
        
if cnt ==N:
    print(sum(taste) + min(taste_abs))
else:
    print(sum(taste) - min(taste_abs))

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

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

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

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

dif = 9999
ans = 0
for i in range(n):
    pre = p[:i]
    post = p[i+1:]

    tmp = sum(pre) + sum(post)

    if abs(sum(p) - tmp) < dif:
        ans = tmp
        dif  = abs(sum(p) - tmp)

print(ans)

Solution (Python):
n=[int(i) for i in input().split()]
array=[]
abs_array=[]
for i in range(1,n[0]+1):
  array.append(n[1]+i-1)
  abs_array.append(abs(n[1]+i-1))
abs_array.sort()
if abs_array[0] in array :
  print(sum(array)-abs_array[0])
else:
  print(sum(array)+abs_array[0])

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

if max(aji) < 0:
    aji.remove(max(aji))
    print(sum(aji))
elif 0 in aji:
    print(sum(aji))
else:
    aji.remove(min(aji))
    print(sum(aji))

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

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

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

res = 0
if m == k:
    res = sum(t) - m
else:
    res = sum(t) + m
print(res)

Solution (Python):
N,L=map(int,input().split())
flag=0
judge=0
ans=[0]*N

for i in range(N):
    flag+=L+i

for i in range(N):
    ans[i]=abs(0-(L+i))

if (N+L)<=0:
    print(flag-(N+L)+1)
else :
    print(flag-min(ans))

Solution (Python):

N, L = list(map(int,input().split()))
all = 0
apple = []
for i in range(N):
    apple.append(L + i)
a = min(apple)
b = max(apple)
if 0 in apple:
    print(sum(apple))
elif b < 0:
    print(sum(apple)-b)
elif a > 0:
    print(sum(apple)-a)

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

aji = []
min_abs = 1000000000000000
min_abs_index = 0
for i in range(1, N + 1):
    if min_abs > abs(L + i - 1):
        min_abs = abs(L + i - 1)
        min_abs_index = i - 1
    aji.append(L + i - 1)

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

Solution (Python):

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








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





print(sum(taste_list)-taste_list[[abs(taste) for taste in taste_list].index(min([abs(taste) for taste in taste_list]))])

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