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 = list(map(int,input().split(" ")))

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

s = sum(apple)

m = 10000000000000
for x in apple:
  if abs(m) > abs(x):
    m = x

print(s-m)

Solution (Python):
N , L = (int(i) for i in input().split())
ans = 0
a = 0
b = L
for i in range(N):
  a = L + i
  ans += a
  if abs(a) < abs(b):
    b = a
print(ans - b)

Solution (Python):
n, l = map(int, input().split())
all_taste = 0
taste_list = list()
for i in range(n):
  taste = l+(i+1)-1
  taste_list.append(taste)
  all_taste += taste

www = float("inf")
for i in range(n):
  if abs(taste_list[i]) < www:
    www = abs(taste_list[i])
    ind = i
ans = all_taste - taste_list[ind]
print(ans)

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

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


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

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

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

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

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











d = 1000
rtn = s

for i in range(1,n+1):
    s_tmp = s - (l + i - 1)
    if (abs(s - s_tmp) < d):
        d = abs(s - s_tmp)
        rtn = s_tmp

print(int(rtn))

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

Solution (Python):
N,L = map(int, input().split())
list = []
sum = 0
min = 10000
sign = 1
for i in range(1,N+1):
    sum += L+i-1
    list.append(L+i-1)
for num in list:
    if min > abs(num):
        min = abs(num)
        if num > 0:
            sign = 1
        else:
            sign = -1
print(sum-min*sign)

Solution (Python):
a=list(map(int,input().split()))
b=list(range(a[1],a[0]+a[1]))
c=min(b)
d=max(b)
if c==0 or d==0:
    e=0
elif c/d>0:
    if c>0:
        e=c
    else:
        e=d
else:
    e=0
print(sum(b)-e)

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

Solution (Python):
n,l = list(map(int, input().split()))
import numpy as np
x = np.arange(l,l+n)
y = np.abs(x)
x = np.delete(x, np.argmin(y))
print(np.sum(x))

Solution (Python):

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


nomal_sum = 0
for number in range(1,N+1):
  nomal_sum = nomal_sum + (L + number -1)

  










list = []
lost_sum = 0
for number in range(1,N+1):
  for number2 in range(1,N+1):
    if number != number2:
      lost_sum = lost_sum + (L + number2 -1)
  list.insert(number, lost_sum)
  lost_sum = 0



minimal1 = 100000
ans = 0
for list_aji in list:
  
  
  
  if minimal1 >= abs(list_aji - nomal_sum):
    minimal1 = abs(list_aji - nomal_sum)
    ans = list_aji
print(ans)

Solution (Python):
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline



def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, L] = [int(input_raw[0]), int(input_raw[1])]
    A = [L + i - 1 for i in range(1, N + 1)]

    abs_min_A = sys.maxint
    abs_min_i = 0
    for i in range(N):
        if abs(A[i]) < abs_min_A:
            abs_min_A = abs(A[i])
            abs_min_i = i
    sum1 = 0
    sum2 = 0
    for i in range(N):
        if i != abs_min_i:
            sum2 += A[i]
    print (sum2)



if __name__ == '__main__':
    main()

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

def taste(x,l):
    return x+l-1
tastes=[]
for i in range(1,n+1):
    tastes.append(taste(i,l))
min = 0
cnt=0
for i in range(0,n):
    if abs(tastes[min]) >= abs(tastes[i]):
        min=i
del tastes[min]


print(sum(tastes))

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

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

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

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

if 0 <= l :
	result = taste_int - l
elif l <= -1 * n :
	result = taste_int - (n + l -1 )
else:
	result = taste_int

print( result)

Solution (Python):
N, L = map(int,input().split())
import statistics
S = []
for i in range(L,N+L):
    S.append(i)
ans = []
p = []
for j in S:
    ans.append(abs(sum(S) - sum(S) - j))
    p.append(sum(S)-j)

print(p[ans.index(min(ans))])

Solution (Python):
import numpy as np
N,L=(int(i) for i in input().split())

list=np.arange(L,N+L,1)

num=0
if np.sum(np.min(np.abs(list))==list)==1:
  num=np.min(np.abs(list))
else:
  num=-np.min(np.abs(list))

score=np.sum(list)-num

print(score)

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


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

array = []
num = 0
for i in range(1,N+1):
    T_i = L + i -1
    T_Ni = T_N - T_i

    T_abs = abs(T_N - T_Ni)
    array.append(T_abs)
    if (min(array) == T_abs):
        num = T_Ni

print(int(num))

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

aji = [(i+1)+int(L)-1 for i in range(int(N))]
abs = list(map(abs, aji))
index = abs.index(min(abs))

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

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

apple_sum = (apples[0] + apples[n-1]) * n / 2
rm = 0

for i, apple in enumerate(apples):
    if abs(apple) < abs(apples[rm]):
        rm = i

apples.pop(rm)
print(sum(apples))

Solution (Python):

N, L = map(int, input().split())
apple = []
for i in range(N):
    apple.append(L + i)
j = 0
for i in range(N):
    if apple[i] == 0:
        a = apple[i]
        del apple[i]
        j += 1
        break


if j == 0:
    if not 0 in apple:
        if apple[0] < 0:
            del apple[-1]
        elif apple[0] > 0:
            del apple[0]
print(sum(apple))

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

total_taste_all = (N**2 + (2*L - 1)*N)/2
min_err = 10000
for i in range(N):
  apple_taste = L + i 
  taste_err = abs(apple_taste)
  if taste_err <= min_err:
    min_err = taste_err
    apple_pie_taste = total_taste_all - apple_taste
    
print(int(apple_pie_taste))

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

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

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


print(sum - m)

Solution (Python):
l,m = map(int,input().split())
lis =[]
lis2=[]
for i in range(l):
  lis.append(m+i)
  lis2.append(abs(m+i))

lis.pop(lis2.index(min(lis2)))
print(sum(lis))

Solution (Python):
import numpy as np

N,L=map(int, input().split())
taste=0
Apple_taste=[]

for i in range(N):
    taste=L+i
    Apple_taste.append(taste)

Abs=[abs(t) for t in Apple_taste]

i_m=np.argmin(Abs)
del Apple_taste[i_m]

print(sum(Apple_taste))

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

    print(count)

if l > 0:
    for i in range(2, n+1):
        count += i + l -1

    print(count)

if (l < 0) and (n > 1 - l):
    for i in range(1, n+1):
        count += i + l - 1

    print(count)
    
if (l < 0) and (n < 1 - l):
    for i in range(1, n):
        count += i + l - 1
        
    print(count)
    
if (l < 0) and (n == 1 - l):
    for i in range(1, n):
        count += i + l -1
        
    print(count)

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

def getMin(arr):
    idx = 0
    curr = abs(arr[0])
    for i in range(1, len(arr)):
        if abs(arr[i]) < curr:
            curr = abs(arr[i])
            idx = i
    return (idx, curr)

f = [(L + i) for i in range(N)]
idx, m = getMin(f)
print(sum([i if i != f[idx] else 0 for i in f]))

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

elif L+N<=1:
    for i in range(N-1):
        X=X+L+i

else:
    for i in range(N):
        X=X+L+i
print(X)

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

s=b-1
m=0

r=0

if b < 1:
    if a + b > 0:
        m = 0
    else:
        m = b + a -1
else:
    m = b

for i in range(a):
    s += 1
    r = r + s
    

print(r-m)

Solution (Python):
import numpy as np
N,L = [int(x) for x in input().split(' ')]
s = np.sum(range(N+1)) + (N - 1) * L - (N - 1)

off = L - 1


if off >= 0:
  s -= 1
else:
  if -off >= N:
    off = -N
  s += off
print(s)

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

taste = [L+i-1 for i in range(1,N+1)]
eat = min(map(abs,taste))
if L+N-1 < 0:
    eat *= -1

print(sum(taste) - eat)

Solution (Python):
def checkio(numbers_array):
    return sorted(numbers_array, key=lambda x: abs(x))


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

    
w_list=checkio(w_list)
ans=0
for i in range(n-1):
    ans=ans+w_list[i+1]

print(ans)

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

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

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

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

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

if min(lst) > 0:
    lst.remove(min(lst))
elif max(lst) < 0:
    lst.remove(max(lst))
else:
    lst.remove(0)

print(sum(lst))

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

if sum(taste) >= 0:
    print(sum(taste) - min(taste_abs))
else:
    print(sum(taste) + min(taste_abs))

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

mini = 100
index = 0
for i in range(N):
  if mini > abs(lis[i]):
    mini = abs(lis[i])
    index = i

print(sum(lis)-lis[index])

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

largest = L + N - 1
smallest = L

passZero = largest * smallest < 0

numSum = N * ( L + N / 2.0 - 0.5)

res = 0
if passZero:
    res = int(numSum)
else:
    if numSum > 0:
        res = int(numSum - L)
    elif numSum == 0:
        res = int(numSum)
    else:
        res = int(numSum-L-N+1)

print(res)

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

for i in range(1, N+1):
    li.append(i)

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

if li2[0] > 0:
    del li2[0]

if li2[-1] < 0:
    del li2[-1]

s = sum(li2)


print(s)

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

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

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

if L >= 0:
    aji = L + 1
    ajiTotal = 0
    for i in range(N - 1):
        ajiTotal = ajiTotal + aji
        aji = aji + 1
    print(ajiTotal)

else:
    if N + L > 0:
        aji = L
        ajiTotal = 0
        for i in range(N):
            ajiTotal = ajiTotal + aji
            aji = aji + 1
        print(ajiTotal)
    else:
        aji = L
        ajiTotal = 0
        for i in range(N - 1):
            ajiTotal = ajiTotal + aji
            aji = aji + 1
        print(ajiTotal)

Solution (Python):

import sys


import numpy as np


"""Template"""


class IP:
    """
    入力を取得するクラス
    """
    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: int
        """
        return int(self.input())

    def S(self):
        """
        1文字の取得(str
        :return: str
        """
        return self.input()

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]

    def SILS(self, n):
        """
        Some Int LineS
        横に複数、縦にも複数
        :param n: 行数
        :return: list
        """
        return [self.IL() for _ in range(n)]

    def SSLS(self, n):
        """
        Some String LineS
        :param n: 行数
        :return: list
        """
        return [self.SL() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        
        
        
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if self.bit_o(i, j):
                    """右からj+1番目のiが1かどうか判定"""
                    
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val

    def S(self, s, r=0, m=-1):
        """
        ソート関係行います。色々な設定あります。
        :param s: 元となるリスト
        :param r: reversするかどうか 0=False 1=True
        :param m: （2次元配列）何番目のインデックスのソートなのか
        :return: None
        """
        r = bool(r)
        if m == -1:
            s.sort(reverse=r)
        else:
            s.sort(reverse=r, key=lambda x: x[m])

    def bit_n(self, a, b):
        """
        bit探索で使います。0以上のときにTrue出します
        自然数だからn
        :param a: int
        :param b: int
        :return: bool
        """
        return bool((a >> b & 1) > 0)

    def bit_o(self, a, b):
        """
        bit探索で使います。1のときにTrue出すよ
        oneで1
        :param a: int
        :param b: int
        :return: bool
        """
        return bool(((a >> b) & 1) == 1)

    def ceil(self, x, y):
        """
        Round up
        小数点切り上げ割り算
        :param x: int
        :param y: int
        :return: int
        """
        return -(-x//y)

    def ave(self, a):
        """
        平均を求めます
        :param a: list
        :return: int
        """
        return sum(a) / len(a)

    def gcd(self, x, y):
        if y == 0:
            return x
        else:
            return self.gcd(y, x % y)

    def lcm(self, x, y):
        return (x * y) // self.gcd(x, y)


"""ここからメインコード"""


def main():
    
    r, e = range, enumerate
    ip = IP()
    id = Idea()

    """この下から書いてね"""
    n, l = ip.IL()
    memo = (1 + n) / 2 * n
    memo2 = memo + l * n
    m = np.arange(0, n)
    m += l
    idx = np.abs(np.asarray(m)).argmin()

    m = np.delete(m, idx)
    print(np.sum(m))

main()

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

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

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

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

Solution (Python):
import sys
from io import StringIO
import unittest
import numpy as np


def resolve():
    N, L = map(int, input().split())
    taste = np.zeros(N)
    for i in range(N):
        taste[i] = L + i
    min_idx = np.argsort(np.abs(taste))[0]
    sum_taste = np.sum(taste) - taste[min_idx]
    print(np.int(sum_taste))

resolve()

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

taste = 0


if l <= 0 and 0 < n + l:
  for i in range(n):
    taste += l + i

elif l <= 0:
  for i in range(n -1):
    taste += l + i

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

print(taste)

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

Solution (Python):
N, L = map(int, input().split())
Sum = 0
Eaten = 114514

for i in range(N):
    if abs(Eaten) > abs(L + i):
        Eaten = L + i
    Sum = Sum + L + i

Sum = Sum - Eaten
print(Sum)

Solution (Python):


import sys
input = sys.stdin.readline

n, l = map(int, input().split())
azi = []
minn = n+l-1
for i in range(1, n+1):
    azi.append(i + l - 1)
    if (abs(minn) >= abs(i + l - 1)):
        minn = i + l - 1
print(sum(azi)-minn)

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

s = 0









if L>0:
    for i in range(2,N+1):
        s += L+i-1
    print(s)
elif L<0 and L*(-1)>N-1:
    for i in range(1,N):
        s += L+i-1
    print(s)
else:
    for i in range(1,N+1):
        s += L+i-1
    print(s)

Solution (Python):
N,L=map(int,input().split())
R=[L+i for i in range(N)]
S=abs(sum(R))
S2=0
for r in R:
    if S >= abs(r) :
        S = abs(r)
        S2 = r
print("{}".format(sum(R)-S2))

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

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

print(int(tsum))

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




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

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

Solution (Python):
import numpy as np
N,L = (int(x) for x in input().split())
sum = N*(2*L+N-1)/2
if L >= 0:
  print(int(sum - L))
elif(L < 0 and L+N-1>0):
  print(int(sum))
else:
  print(int(sum - (L+N-1)))

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

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

    
    abs_taste = []
    for i in taste:
        abs_taste.append(abs(i))

    m = abs_taste.index(min(abs_taste))
    
    taste.pop(m)
    

    print(sum(taste))

main()

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

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

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

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

list.sort(key=lambda x: abs(x))

del list[0]

print(sum(list))

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

print(min(aji_list)[1])

Solution (Python):
num = input().split()
amount = int(num[0])
aji_list = [int(num[1])+i for i in range(amount)]

original_aji = sum(aji_list)
smallest = abs(aji_list[0])

for i in aji_list:
  if abs(i)<abs(smallest): smallest = i
    
print(original_aji-smallest)

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

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

result = 0
if L > 0:
    current = L + 1
    for i in range(0, N - 1):
        result = result + current
        current = current + 1
elif L + N - 1 < 0:
    current = L
    for i in range(0, N - 1):
        result = result + current
        current = current + 1
else:
    current = L
    for i in range(0, N):
        result = result + current
        current = current + 1
print(result)

Solution (Python):



def ri():
    return int(input())

def rl():
    return list(input().split())

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

def main():
    n, l = rli()
    taste = 0
    m = 999999999
    t_min = 0
    for i in range(n):
        t = l + i
        if abs(t) < m:
            m = min(m, abs(t))
            t_min = t
        taste += t
    print(taste-t_min)


if __name__ == '__main__':
    main()

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

print(ans)

Solution (Python):



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



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


aji_list = range(L, L+N, 1)
aji_abs_list = list(map(abs, aji_list))
aji_abs_list.sort()
min_list = aji_abs_list[0]

min_minus = min_list * -1
if L <= min_minus <= L+N:
    min_list = min_minus


print(int(total - min_list))

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

if l>=0:
    print(int((2*l+n)*(n-1)/2))
else:
    if abs(l)<n:
        print(int((2*l+n-1)*n/2))
    else:
        print(int((2*l+n-2)*(n-1)/2))

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

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

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

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

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

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

Solution (Python):
n,l = map(int,input().split())
def apple(a,b):
    if a == 0:
        return 0
    return apple(a-1,b)+ b+a-1

cor = apple(n,l)
wro = apple(n-1,l)
for i in range(1,n):
    if abs(l+i-1) < abs(wro-cor) :
        wro = cor -(l+i-1)
    else:
        wro += 0

print(wro)

Solution (Python):
def main():

    
    

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

    moto = 0

    min = l + 1 - 1
    min = abs(min)
    default_i = 1

    for i in range(n):
        i += 1
        aji = l + i -1
        abs_aji = abs(aji)
        if(abs_aji < min):
            min = abs_aji
            default_i = i

        moto += aji
    
    tabeta = moto - (l + default_i - 1)
    
    print(tabeta)


if __name__ == '__main__':
    main()

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

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

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

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

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

Solution (Python):

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



a=[]
check=L
min_i=0
for i in range(N):
    a.append(L+i)

    if(abs(a[i])<abs(check)):
        check=abs(a[i])
        min_i=i
    
print(sum(a)-a[min_i])

Solution (Python):
N,L = list(map(int, input().split()))
m = 1000000000
k = 0
s = 0

for i in range(1,N+1):
    h = abs(L+i-1) 
    if h <= m :
        m = h
        k = i

for i in range(1,N+1):
    if i != k:
        s = s + L + i - 1
        
print(s)

Solution (Python):
n, l = map(int, input().split())
apples = list(range(l, l + n))
if 0 in apples:
    print(sum(apples))
elif l < 0:
    print(sum(apples) - max(apples))
else:
    print(sum(apples) - min(apples))

Solution (Python):
N, L = list(map(int, input().split()))
taste = [L+i-1 for i in range(1, N+1)]
abs_taste = list(map(lambda x: abs(x), taste))
argmin = abs_taste.index(min(abs_taste))
cnt = 0
x = sum([taste[n] for n in range(N) if n != argmin])
print(x)

Solution (Python):
import numpy as np
N,L = list(map(int, input().split()))
l_num = np.arange(L,(L+N))
wa = np.sum(l_num)
if any(l_num<0):
	print(wa + np.min(np.abs(l_num)))
else:
	print(wa-np.min(np.abs(l_num)))

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

ideal = sum(numlist)
salist = []
for i in range(N):
    a = numlist.pop(i)
    suma = sum(numlist)
    salist.append(suma)
    numlist.insert(i,a)


anslist = []
lastans = 0
for i in range(len(salist)):
    if i == 0:
        sa = salist[i] - ideal
        anser = i
    else:
        if abs(salist[i] - ideal) < sa:
            sa = salist[i] - ideal
            anser = i

print(salist[anser])

Solution (Python):
n, f  = input().split(' ')
flavors =  []
for i in range(int(n)):
    flavors.append(i + int(f))



min_v = abs(flavors[0])
for i in flavors:
    if abs(i) < abs(min_v):
        min_v = i
      

print(sum(flavors) - min_v)

Solution (Python):
import numpy as np
N,L = map(int,input().split())
azi = [i+L for i in range(N) ]
azi_abs = np.abs(azi)

if 0 in azi:
    print(sum(azi))
else:
    apple_azi = [abs(sum(azi)-sum(azi)-azi[i]) for i in range(len(azi))]
    if sum(azi) >= 0:
        print(sum(azi)-min(apple_azi))
    else:
        print(sum(azi)+min(apple_azi))

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

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

Solution (Python):

N,L = [int(i) for i in input().split()]
list=[]
s=N*(L-1)
for i in range(1,N+1):
    s +=i
    list.append(abs(L+i-1))
a=0
if s<0:
    a=s+min(list)
else:
    a=s-min(list)

print(a)

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

Solution (Python):



azi = []
N,L = map(int,input().split())

for i in range(N):
    azi.append(L+i)
all = sum(azi)

wa = 0
ans=0
min = 999999

for i in range(N):
    wa = 0
    for j in range(N):
        if (i != j):
            wa += azi[j]
    if abs(all-wa) < min:
        min = abs(all-wa)
        ans = wa 

print (ans)

Solution (Python):
N, L = map(int, input().split())
a = N * (L - 1) + N * (N + 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 = []

l = [L+i for i in range(N)]
total = sum(l)
for i in range(N):
    total2 = total - l[i]
    ans += [abs(total - total2)]
print(total-l[ans.index(min(ans))])

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

Solution (Python):

import sys


def solve(N: int, L: int):
    ls = [L + x for x in range(0, N)]

    if L > 0:
        del ls[0]
        print(sum(ls))

        return

    elif ls.__contains__(0):
        print(sum(ls))

        return
    else:
        del ls[-1]
        print(sum(ls))

        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=map(int,input().split())
a=[]
ab=1000
memo=1000
for i in range(1,N+1):
    a.append(L+i-1)
    if abs(L+i-1)<=ab:
        ab=abs(L+i-1)
        memo=L+i-1
print(sum(a)-memo)

Solution (Python):
import numpy as np
N, L = map(int, input().split()) 
arr = np.array(list(range(L, L + N)))
square_arr = np.square(arr)
min_value = square_arr.min()
print(np.sum(arr[~(square_arr==min_value)]))

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

A=[0]*N
B=[0]*N

for i in range(N):
  A[i]=L+i
  B[i]=abs(L+i)
  if MM>abs(A[i]):
    MM=A[i]
  



if MM>0:
  print(sum(A)-min(B))
else:
  print(sum(A)+min(B))

Solution (Python):
def main(str):
    input = str.split()
    n = int(input[0])
    l = int(input[1])
    apples = [l + i for i in range(n)]
    abs_apples = list(map(lambda x: abs(x), apples))
    return sum(apples) - apples[abs_apples.index(min(abs_apples))]


if __name__ == "__main__":
    str = input()
    print(main(str))

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

al = []
for i in range(n):
    aji = l + i
    aji_ = abs(aji)
    al += [aji_]

x = abs(l)
an = 0
for i in range(n):
    if al[i] < x:
        x = al[i]
        an = i

ans = (l + l+n-1)*n/2 - (l+an)
print(int(ans))