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 = tuple([int(x) for x in input().split(' ')])

s = [L+i for i in range(N)]
l = [abs(L+i) for i in range(N)]
ind = l.index(min(l))
s.pop(ind)

print(sum(s))

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

s = sum(val)
small = 10000
for i in val:
    if abs(i) < small:
        small = abs(i)
        memo = i

if memo < 0:
    print(s+small)
else:
    print(s-small)

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

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

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

Solution (Python):

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

n = i[0]
l = i[1]

aji = [] 

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

ajimap = list(map(abs, aji))

idx = ajimap.index(min(ajimap))

sum = 0

for i in range(n):
  if i != idx:
    sum += aji[i]
    
print(sum)

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

abs_min_taste = 9999
min_i = -1
for i in range(N):
    if abs_min_taste > abs(taste[i]):
        min_i = i
        abs_min_taste = abs(taste[i])

sum_taste = sum(taste)
ans = sum_taste - taste[min_i]

print(ans)

Solution (Python):
import numpy as np

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

taste_list = np.arange(L, (L+N))

if min(taste_list) > 0:
    print(sum(taste_list) - min(taste_list))
elif max(taste_list) < 0:
    print(sum(taste_list) - max(taste_list))
else:
    print(sum(taste_list))

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

sum_of_taste = sum(taste)

base = 10**10
answer = 0
for i in taste:
  if base > abs(i):
    base = abs(i)
    answer = sum_of_taste - i

print(answer)

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

Solution (Python):
import sys

fin = sys.stdin.readline
N, L = [int(elem) for elem in fin().split()]

all_sum = N * (1 + N) / 2 + L * N - N
i = min(max(1, 1 - L), N)
reduce_num = L + i - 1
print(int(all_sum - reduce_num))

Solution (Python):

n,l = list(map(int,input().split()))
apple_list = [i for i in range(l,l+n)]
max_al = max(apple_list)
min_al = min(apple_list)
ret = sum(apple_list)
if 0 not in apple_list:
    if abs(max_al) >= abs(min_al):
        ret -= min_al
    else:
        ret -= max_al
print(ret)

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

taste = [0] * N
minimum = 10000
minAbs = 10000

for i in range(N) :
    taste[i] = L + i
    if abs(taste[i]) < minAbs :
        minimum = taste[i]
        minAbs = abs(taste[i])

print(sum(taste) - minimum)

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

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

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

apples = range(l, n+l)
print(sum(sorted(apples, key=lambda x: abs(x))[1:]))

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

print(sum(l) - b)

Solution (Python):
import numpy as np
n, l = map(int, input().split())

b = np.array([l + i for i in range(n)])
a = b.sum()

idx = np.argmin(np.abs(b))

print(a - b[idx])

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

aaa = [l + x for x in range(n)]
sum_aaa = sum(aaa)
tmp = float("inf")
for a in aaa:
    if abs(sum_aaa - (sum_aaa - a)) < tmp:
        tmp = abs(sum_aaa - (sum_aaa - a))
        res = sum_aaa - a
print(res)

Solution (Python):
n,l=map(int,input().split())
s=[]
i=0
while i!=n:
    x=[abs(l+i),l+i]
    s.append(x)
    i+=1
s.sort()
i=1
ans=0
while i!=n:
    ans+=s[i][1]
    i+=1

print(ans)

Solution (Python):

def input_from_console():
    n, l = map(int, input().split())
    return n, l


def solve(n, l):
    all_data = [ l + item for item in range(n)]
    new_list = sorted([abs(item) for item in all_data])
    if new_list[0] in all_data:
        result = sum(all_data) - new_list[0]
    else:
        result = sum(all_data) + new_list[0]
    return result


def main():
    n, l = input_from_console()
    print(solve(n, l))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  
        check_cases()
    else:
        main()

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

a = list(range(L+1-1, L+N-1+1))
a.sort(key=lambda x: abs(x))

print(sum(a[1:]))

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

Solution (Python):
n,l=(int(i) for i in input().split())
r=l
s=0
for i in range(n):
  if l+i<=0:
    r=l+i
  s=s+l+i
print(s-r)

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

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



l = []

min_a = N + abs(L) * N * N + N


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

    if abs(a) < abs(min_a):
        min_a = abs(a)
        ans_i = i



    l.append(a)


ans = sum(l) - l[ans_i]

print(ans)

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

Solution (Python):
def read():
    N, L = list(map(int, input().strip().split()))
    return N, L


def solve(N, L):
    tastes = [-1] * N
    min_abs_index = 0
    for i in range(N):
        tastes[i] = L + (i+1) - 1
        if abs(tastes[i]) < abs(tastes[min_abs_index]):
            min_abs_index = i
    return sum(tastes[0:min_abs_index]) + sum(tastes[min_abs_index+1:N])


if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))

Solution (Python):
import sys

readline = sys.stdin.readline

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

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

a = [abs(L + i) for i in range(N)]
b = min(a)
c = a.index(b) + L

print(total - c)

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

Solution (Python):
s = input().split(' ')
n = int(s[0])
l = int(s[1])
if l > 0:
  m = (l + n+l-1) * n / 2 - l
  print(int(m))
elif l < 0 and (n+l-1) < 0:
  m = (l + n+l-1) * n / 2 - (n+l-1)
  print(int(m))
else:
  m = (l + n+l-1) * n / 2
  print(int(m))

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

Solution (Python):







import sys
sys.setrecursionlimit(10**7)
from itertools import accumulate, combinations, permutations 
from math import factorial
def factorize(n):
    """return the factors of the Arg and count of each factor
    
    Args:
        n (long): number to be resolved into factors
    
    Returns:
        list of tuples: factorize(220) returns [(2, 2), (5, 1), (11, 1)]
    """
    fct = []  
    b, e = 2, 0  
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct
def combinations_count(n, r):
    
    
    
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
    return result
def combination_with_repetition_count(n, r):
    return combinations_count(n + r - 1, r)
from collections import deque, Counter 
from heapq import heapify, heappop, heappush, heappushpop, heapreplace,nlargest,nsmallest 
from copy import deepcopy, copy 
from operator import itemgetter 


from functools import reduce
from fractions import gcd 
def gcds(numbers):
    return reduce(gcd, numbers)
def lcm(x, y):
    return (x * y) // gcd(x, y)
def lcms(numbers):
    return reduce(lcm, numbers, 1)



INF = 10 ** 18
MOD = 10 ** 9 + 7
modpow = lambda a, n, p = MOD: pow(a, n, p) 
def modinv(a, p = MOD):
    
    
    return modpow(a, p-2, p)
def modinv_list(n, p = MOD):
    if n <= 1:
        return [0,1][:n+1]
    else:
        inv_t = [0,1]
        for i in range(2, n+1):
            inv_t += [inv_t[p % i] * (p - int(p / i)) % p]
        return inv_t
def modfactorial_list(n, p = MOD):
    if n == 0:
        return [1]
    else:
        l = [0] * (n+1)
        tmp = 1
        for i in range(1, n+1):
            tmp = tmp * i % p
            l[i] = tmp
        return l
def modcomb(n, k, fac_list = [], p = MOD):
    
    
    from math import factorial
    if n < 0 or k < 0 or n < k: return 0
    if n == 0 or k == 0: return 1
    if len(fac_list) <= n:
        a = factorial(n) % p
        b = factorial(k) % p
        c = factorial(n-k) % p
    else:
        a = fac_list[n]
        b = fac_list[k]
        c = fac_list[n-k]
    return (a * modpow(b, p-2, p) * modpow(c, p-2, p)) % p
def modadd(a, b, p = MOD):
    return (a + b) % MOD
def modsub(a, b, p = MOD):
    return (a - b) % p
def modmul(a, b, p = MOD):
    return ((a % p) * (b % p)) % p
def moddiv(a, b, p = MOD):
    return modmul(a, modpow(b, p-2, p))




    
    

    
    
    
    
    

    
    





r = lambda: sys.stdin.readline().strip() 
R = lambda: list(map(int, r().split())) 
Rmap = lambda: map(int, r().split())


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

Solution (Python):
def resolve():
    (N, L) = list(map(int, input().split(" ")))
    Ts = []
    offset = L - 1
    absmin = float('inf')
    mini = float('inf')
    for i in range(1, N+1):
        Ts.append(i+offset)
        if abs(i + offset) < absmin:
            absmin = abs(i + offset)
            mini = i + offset
    print(sum(Ts)-mini)
        
    
if '__main__' == __name__:
    resolve()

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

cnt = 0
m = None
for i in range(L, L+N):
    cnt += i
    if m is None:
        m = i
    elif abs(i) < abs(m):
        m = i
print(cnt-m)

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

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


print("{}".format(ans))

Solution (Python):
import numpy as np

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

tastes = np.arange(N) + L
idx = np.argmin(np.abs(tastes))
tastes[idx] = 0
print(np.sum(tastes))

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

S_list = []
S = 0
for i in range(N):
    S_list.append(i+L)
    S += (i+L)


m = 1000
M = -1000
f = 0
for s in S_list:
    if s < m:
        m = s
    if M < s:
        M = s
    if s == 0:
        f = 1
        break

if f == 0:
    if S > 0:
        S = S - m
    else:
        S = S - M

print(S)

Solution (Python):
from sys import stdin

N, L = list(map(int, stdin.readline().split()))

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

absAppleList = [abs(s) for s in appleList]


print(sum(appleList)-appleList[absAppleList.index(min(absAppleList))])

Solution (Python):
n,l=map(int,input().split())
absmin = 10**9
absmint = 10**9
sum_ = 0
for i in range(n):
    t = i+l
    sum_ += t
    
    if absmin > abs(t):
        absmin = abs(t)
        absmint = t
        
sum_ -= absmint 
print(sum_)

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

mingo = 1000

cnt = 0
sumringo = 0
while cnt < N:
    sumringo += L
    if abs(L) < mingo:
        eatringo = L
        mingo = abs(L)
    L += 1
    cnt += 1

print(sumringo - eatringo)

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

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

for t in tastes:
    if abs(t) < abs(m):
        m = t

print(sum(tastes) - m)

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

Solution (Python):
inp = [int(i) for i in input().split()]
aa = []
for d in range(inp[1],inp[1]+inp[0]):
    aa.append(d)

if 0 in aa:
    pass
elif aa[-1] <= 0:
    aa.pop(-1)
else:
    aa.pop(0)

print(sum(aa))

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

elif N>abs(L):
    for i in range(N):
        total += L
        L += 1

else:
    for i in range(N-1):
        total += L
        L += 1
print(total)

Solution (Python):
def sgn(X):
    if X > 0:
        return 1
    elif X < 0:
        return -1
    else:
        return 0

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

taste = [0] * N
taste[0] = 10000

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

taste2 = list(map(abs, taste))

print(sum(taste) - sgn(sum(taste)) * min(taste2))

Solution (Python):
import numpy as np
N, L =  list(map(int,input().split(" ")))
taste = np.arange(N) +  L
diff_taste_min = np.argmin(np.abs(taste))
print(np.sum(taste) - taste[diff_taste_min])

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

sum_n = 0
min_abs = 20000
for i in range(N):
    sum_n+=L+i
    min_abs=min(min_abs, abs(L+i))
if sum_n>0:
    print(sum_n-min_abs)
else:
    print(sum_n+min_abs)

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

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

Solution (Python):
import numpy as np
n, l = list(map(int, input().split()))
ringos = np.array([l + i for i in range(n)])
eatringo = min(np.abs(ringos))
if eatringo in ringos :
    print(sum(ringos)-eatringo)
else :
    print(sum(ringos)+eatringo)

Solution (Python):
def bite_eating(N: int, L: int)->int:
    total = N*(N-1)//2 + L*N

    if L >= 0:
        
        return total-L

    if N+L-1 < 0:
        
        return total-(N+L-1)

    
    
    return total


if __name__ == "__main__":
    N, L = map(int, input().split())

    ans = bite_eating(N, L)
    print(ans)

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


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

aji_abs = list(map(abs, aji))
min_tmp = float('inf')
indx = -1
for i, x in enumerate(aji_abs):
    if x < min_tmp:
        min_tmp = x
        indx = i

ans = sum(aji)
ans -= (aji[indx])

print(ans)

Solution (Python):
import sys
from collections import deque  
from collections import defaultdict  
from heapq import heapify, heappush, heappop, heappushpop  
from bisect import bisect_left, bisect_right  



s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, L = i2nn()
    a = L
    b = L + N - 1
    n = 0
    for i in range(a, b+1):
        n += i
    if a <= 0 and b >= 0:
        n -= 0
    else:
        c = abs(a)
        d = abs(b)
        if c < d:
            n -= a
        else:
            n -= b
    print(n)

main()

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


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


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


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

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

minScore = l

sum = 0
for i in range(1, n + 1):
    score = l + i - 1
    sum += score
    if abs(score) < abs(minScore):
        minScore = score

print(sum - minScore)

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

Solution (Python):


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

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

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

print(ans)

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

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

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

wk = 101

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

Solution (Python):
def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    [n, l] = li()
    sum_taste = (2 * l + n - 1) * n // 2
    if l <= 0 <= l + n - 1:
        print(sum_taste)
    elif l < 0:
        print(sum_taste - (l + n - 1))
    else:
        print(sum_taste - l)

Solution (Python):
import math


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







kotae = 0

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

print(int(kotae))

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

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

j, k = 0, 99999
for i in range(N):
    if k > abs(T[i]):
        j, k = i, abs(T[i])

print(sum(T) - T[j])

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

t = [l + i - 1 for i in range(1, n + 1)]
t_min = 9999
for i in t:
    if abs(i) < abs(t_min):
        t_min = i
print(sum(t) - t_min)

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

aji = []
aji_abs = []
for i in range(1, N+1):
    aji.append(L+i-1)
    aji_abs.append(abs(L+i-1))
eaten = min(aji_abs)
if eaten*(-1) in aji:
    eaten = - eaten

all = sum(aji) - eaten
print(all)

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

apple = [L + i -1 for i in range(1,N+1) ]
apple.remove(min(apple, key=abs))

print(sum(apple))

Solution (Python):
n, l = map(int, input().split())
min = 9999999
wa = 0
pm = 'p'
for i in range(1, n+1):
    wa += l+i-1
    if abs(l+i-1) < min:
        min = abs(l+i-1)
        if 0 < l+i-1:
            pm = 'm'
        else:
            pm = 'p'
if pm != 'p':
    print(wa-min)
else:
    print(wa+min)

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

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

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

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

print(ans)

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

x = [L+i-1 for i in range(1, N+1)]
x_abs = [abs(L+i-1) for i in range(1, N+1)]
min_index = x_abs.index(min(x_abs))

x.remove(x[min_index])

print(sum(x))

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

ans = 0

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

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

Solution (Python):
def solve():
  N, L = map(int, input().split())
  apples = list(range(L, N + L))
  eat = min(apples, key=abs)
  return sum(apples) - eat

print(solve())

Solution (Python):
N, L=map(int, input().split())
a=list(range(L, N+L))
if min(a)>=0:
    b=min(a)
elif max(a)<=0:
    b=max(a)
else:
    b=0
print(sum(a)-b)

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

N, L = map(int, input().split())
m = [None] * N

for i in range(N):
    m[i] = L + i
    
a = 10 ** 18
index = 0
for i in range(N):
    t = abs(sum(m) - (sum(m) - m[i]))
    
    if a > t:
        a = t
        index = i
        
ans = 0
for i in range(N):
    if i != index:
        ans += m[i]
        
print(ans)

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

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

tlist=[]
for i in range(N):
  tlist.append(L+i)
  

sum_all = sum(tlist)
min_diff = 10000
aji = 0
for i in range(N):
  ringo = tlist[i]
  sum_min1 = sum_all-ringo
  
  if abs(sum_all-sum_min1) < min_diff:
    min_diff = abs(sum_all-sum_min1)
    aji = sum_min1
    
print(aji)

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

eat = abs_aji.index(min(abs_aji))
print(sum(aji) - aji[eat])

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

s = n * (l - 1) + n * (n + 1) // 2

if (0 < l):
    print(s - l)
elif (l+n-1 < 0):
    print(s- (l + n - 1))
else:
    print(s)

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

aji = [L + i + 1 - 1 for i in range(N)]
saishouzettai = 999999
for v in aji:
    if abs(v) < abs(saishouzettai):
        saishouzettai = v

print(sum(aji)-saishouzettai)

Solution (Python):
N, L = map(int, input().split())
Min = L
Max = L + N - 1
answer = L*N
for x in range(N):
    answer += x
if Min > 0:
        answer -= L
else:
    if Max < 0:
        answer -= Max
print(answer)

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

taste = [l + i for i in range(n)]
abs_taste = [abs(i) for i in taste]
min_idx = abs_taste.index(min(abs_taste))
print(sum(taste) - taste[min_idx])

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



if list[0] < 0 and list[N-1] > 0:
    pass
elif list[0] < 0:
    list[N-1] = 0
elif list[0] > 0:
    list[0] = 0
print(sum(list))

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

t = []
for i in range(n):
    t.append(i+l)
max = sum(t)

d = 10**9
ans = 0
for i in range(n):
    if d >= abs(max-(max-t[i])):
        ans = max-t[i]
        d = abs(max-(max-t[i]))

print(ans)

Solution (Python):
import numpy as np

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

arr = np.array(range(n)) + l
arr_abs = abs(arr)
a = np.argmin(arr_abs)
lst = list(arr)
lst.pop(a)
print(sum(lst))

Solution (Python):
import sys
from collections import Counter, deque, defaultdict
from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
from functools import reduce
from math import ceil, floor, log10, log2, factorial
from pprint import pprint

sys.setrecursionlimit(1000000)






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

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

ans = sum(L)
L1 = list(filter(lambda x: x >= 0, L))
L2 = list(filter(lambda x: x < 0, L))

if len(L2) == 0:
    ans -= min(L1)
elif len(L1) == 0:
    ans -= max(L2)
else:
    if abs(min(L1)) < abs(max(L2)):
        ans -= min(L1)
    else:
        ans -= min(L2)

print(ans)

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

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

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

Solution (Python):
N,L = map(int,input().split(' '))
ans = 300
flag = True
total = 0
for i in range(1,N+1):
    tmp = L+i-1
    if ans>abs(tmp):
        ans = abs(tmp)
        if tmp>=0:
            flag = True
        else:
            flag = False
    total += tmp

if flag:
    total -= ans
else:
    total += ans
print(total)

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

Solution (Python):
from collections import Counter
import math
N ,L= map(int, input().split())
applesum=(L+L+N-1)*N//2
if 0 >= L and L+N-1 >= 0:
	print(applesum)
elif 0 > L+N-1 :
	print(applesum-L-N+1)
else:
	print(applesum-L)

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

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

arr = []
for i in range(N):
    arr.append(L+i)

tmp = 1000000
for i in range(N):
    if abs(arr[i]) < tmp:
        tmp = abs(arr[i])
        ans = i

print(sum(arr) -  arr[ans])

Solution (Python):
n,l=map(int, input().split())
ll = sorted(list(map(lambda x: x+l-1, list(range(1,n+1)))))
tmp, ind = 10 ** 8, 10 ** 8
for i, ringo in enumerate(ll):
    if abs(ringo) < tmp:
        ind = i
        tmp = abs(ringo)
ll.pop(ind)
print(sum(ll))

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

s = sum(range(L, L+N))
LL = L + N - 1
if L >= 0:
    print(s - L)
elif L < 0 and LL >= 0:
    print(s)
elif L < 0 and LL < 0:
    print(s - LL)

Solution (Python):




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

psum = 0
pmin = 1000

for i in range(n):
    wkl = l + i
    psum += wkl
    if abs(wkl) < pmin:
        pmin = abs(wkl)
        pmin_v = wkl

psum -= pmin_v


print(psum)

Solution (Python):

def debug(*args):
    import sys
    print(*args, file=sys.stderr)

def solve(N, L):
    A = [0] * N
    for i in range(1, N+1):
        A[i-1] = L+i-1

    m = float("inf")
    debug(A)
    for i in range(0, N):
        res = sum(A[:i]) + sum(A[i+1:])
        t = abs(sum(A) - sum(A[:i]) - sum(A[i+1:]))
        
        if t < m:
            m = t
            ans = sum(A[:i]) + sum(A[i+1:])
    return ans

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

main()

Solution (Python):
N, L = map(int, input().split())
total = N * (L - 1) + N * (N + 1) // 2
tmp = total
sub = abs(total)
for i in range(N):
    if sub > abs(L + i):
        sub = abs(L + i)
        tmp = total - (L + i)
print(tmp)

Solution (Python):
from sys import stdin

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

apples = [L + i for i in range(N)]
apples_minus = sorted([x for x in apples if x <= 0], reverse=True)
apples_minus.append(-10 ** 8)
apples_plus = sorted([x for x in apples if x >= 0])
apples_plus.append(10 ** 8)
eat = 0
if abs(apples_minus[0]) <= abs(apples_plus[0]):
    eat = apples_minus[0]
else:
    eat = apples_plus[0]
print(sum(apples) - eat)

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

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

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