Problem:
 Score : 200 points    Problem Statement You have N apples, called Apple 1 , Apple 2 , Apple 3 , ..., Apple N . The flavor of Apple i is L+i-1 , which can be negative.  You can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.  You planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.  You want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.  Find the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.  We can prove that this value is uniquely determined.      Constraints  2 \leq N \leq 200  -100 \leq L \leq 100  All values in input are integers.         Input Input is given from Standard Input in the following format:  N  L       Output Find the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.        Sample Input 1 5 2      Sample Output 1 18  The flavors of Apple 1 , 2 , 3 , 4 , and 5 are 2 , 3 , 4 , 5 , and 6 , respectively. The optimal choice is to eat Apple 1 , so the answer is 3+4+5+6=18 .       Sample Input 2 3 -1      Sample Output 2 0  The flavors of Apple 1 , 2 , and 3 are -1 , 0 , and 1 , respectively. The optimal choice is to eat Apple 2 , so the answer is (-1)+1=0 .       Sample Input 3 30 -50      Sample Output 3 -1044

Solution (Python):

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

li = list(i for i in range(1, n+1, 1))
ab = 10000
ans = 0

for i in li:
  if abs(l + i - 1) < ab:
    ab = abs(l + i - 1)
    ans = l + i - 1

su = sum(li) + n * l - n

print(su - ans)

Solution (Python):
n, l = map(int, input().split())
apple_sum = n * (2 * l + n - 1) // 2
ate_apple = []
num = 0
for i in range(n):
    ate_apple.append(l + i)
for i in range(1, n):
    if abs(ate_apple[i - 1]) > abs(ate_apple[i]):
        num = i
print(apple_sum - ate_apple[num])

Solution (Python):



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

l = a
r = n + a -1

if r <= 0:
    eat = r
elif l >= 0:
    eat = l
else:
    eat = 0

ans = (r + l) * (r - l + 1) / 2 - eat
print(int(ans))

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

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


abs_R = [abs(i) for i in R]

idx = abs_R.index(min(abs_R))

ans = 0
for i, r in enumerate(R):
    if i == idx:
        continue
    ans += r
print(ans)

Solution (Python):

N, L = [int(s) for s in input().split()]
tastes = [L + i - 1 for i in range(1, N + 1)]

index = 0
taste = 500

for i in range(N):
    if abs(tastes[i]) < taste:
        index = i
        taste = abs(tastes[i])

tastes.pop(index)
print(sum(tastes))

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

taste = list(range(1, N+1))
for a in range(0, N):
    taste[a] = taste[a] + L - 1

abs_taste = copy.deepcopy(taste)

for a in range(0, N):
    abs_taste[a] = abs(abs_taste[a])

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


print(sum(taste))

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

N, L = MAP()
aa = []
sum = 0

for i in range(1, N+1):
	sum += L + i - 1  
	aa.append([i, abs(L + i -1)])

aa.sort(key = lambda x:x[1])

remove = L + aa[0][0] - 1

print(sum-remove)

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

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

if l >= 0 :
    ans = aji - l
elif l < 0 and l+n <= 0 :
    ans = aji - (l+n-1)
else :
    ans = aji

print(int(ans))

Solution (Python):
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, L = il()
    R = range(L, L+N)
    mi = float('inf')
    sm = 0
    for n in R:
        mi = min(mi, abs(n))
        sm += n
    print(sm - mi if sm > 0 else sm + mi)


if __name__ == '__main__':
    main()

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

min=100
sum=0
for i in range(1,N+1):
  if abs(L+i-1)<=abs(min):
    min= L+i-1
  sum += L+i-1 
  
sum -= min

print(sum)

Solution (Python):
icase=0
if icase==0:
    n,l=map(int,input().split())
    s=n*(l-1)+n*(n+1)//2
    smin=200*200
    for i in range(1,n+1):
        ss=abs((l+i-1))

        if smin>ss:
            smin=ss
            sv=s-(l+i-1)

    print(sv)

Solution (Python):
N,L = map(int,input().split())
NL = [int(i)+L-1 for i in range(1,N+1)]
SNL = sum(NL)
ate = 10**18
count = 0
for i in range(N):
  ate = min(ate,abs(NL[i]))
  if ate == abs(NL[i]):
    count = i
print(SNL-NL[count])

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

if __name__ == '__main__':
  main()

Solution (Python):
import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7


def main():
  N, L = map(int, readline().split())
  A = [L+i-1 for i in range(1, N+1)]
  S = sum(A)
  diff = INF
  ans = 0
  for i in range(N):
    x = S - A[i]
    d = abs(S-x)
    if d<diff:
      diff = d
      ans = x
  
  
  print(ans)
  
  
  
  
      
if __name__ == '__main__':
  main()

Solution (Python):
def main():
    N, L = map(int, input().split())
    apple = [ L + i - 1 for i in range(1, N + 1)]
    taste = 0
    tmin = 10**9
    t = sum(apple)
    for i in range(N):
        eat = 0
        for j in range(N):
            if j != i:
                eat += apple[j]
        if abs(eat - t) < tmin:
            tmin = abs(eat - t)
            taste = eat
    print(taste)
main()

Solution (Python):
def resolve():
    n, l = map(int, input().split())
    alist =[l+i for i in range(n)]
    total = sum(alist)
    minimum = 10000
    j = 0
    for i in range(n):
        diff = abs(alist[i])
        if minimum > diff:
            minimum = diff
            j = i
    print(total-alist[j])
resolve()

Solution (Python):
n, l = map(int,input().split())
r = []
for i in range(1,n+1):
  r.append( l + i - 1 )
for i in range(400):
  for j in range(n):
    if abs(r[j]) == i:
      print(sum(r)-int(r[j]))
      exit()

Solution (Python):
n,l=map(int,input().split())
taste=[l+i-1 for i in range(1,n+1)]
b=sum(taste)
x=0
e=float('inf')
for i in taste:
    if e>abs(i):
        e=abs(i)
        x=i

print(b-x)

Solution (Python):
def main():
    N, L = (int(i) for i in input().split())
    s = sum(L + i for i in range(N))
    ans = 10**9
    for i in range(N):
        eat = L + i
        if abs(eat) < abs(ans):
            ans = eat
    print(s - ans)


if __name__ == '__main__':
    main()

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

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

ans = 10**20
Sum = 0
for i in range(n):
    s = l+i
    if ans > abs(s):
        ans = abs(s)
        arr = s
    Sum += s
    
print(Sum-arr)

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

Solution (Python):
n,l = map(int,input().split())
mn = 1000
sums = 0
for i in range(n):
    taste = l+i
    sums += taste
    
for i in range(n):
    taste = l+i
    if mn > abs(taste):
        ans = taste
        mn = abs(taste)
print(sums-ans)

Solution (Python):
n, l = map(int, input().split())
total = [l+(i+1)-1 for i in range(n)]
m = 100000000
for i in range(n):
    if abs(total[i]) < m:
        idx = i
        m = abs(total[i])
total.pop(idx)
print(sum(total))

Solution (Python):
n,l = [int(i) for i in input().split(' ')]
a = sorted([l+i-1 for i in range(1,n+1)])
x = 0
ab = 101
for i in a:
    if abs(i) < ab:
        ab = abs(i)
        x =  sum(a) - i

print(x)

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

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

Sum = 0

for i in range(n):
    Sum += l + i

ans = 10**18

for i in range(n):
    s = l + i
    if ans > abs(-s):
        ans = min(ans, abs(Sum-Sum-s))
        t = s

if t < 0:
    print(Sum+ans)
else:
    print(Sum-ans)

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


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

elif L * N - 1 < 0:
    print(tot - (L + N - 1))

else:
    print(tot - L)

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

if 0 in u:
    print(sum(u))
elif u[-1] < 0:
    print(sum(u)-u[-1])
else:
    print(sum(u)-u[0])

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

a = 200
I = ""
for i in range(N):
  if abs(n[i]) < a:
    a = abs(n[i])
    I = i
print(sum(n) - n[I])

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

a = [(int(i)) for i in range(m, m+n)]
t=100000
ne = False
for i in range(len(a)):
    if t>abs(a[i]):
        inde = i
        t=abs(a[i])
a[inde]=0
print(sum(a))

Solution (Python):
N,L=map(int, input().split())
sm=0
mn=10**10
mn2=0
for i in range(N):
    sm += L+i
    if mn > abs(L+i):
        mn = abs(L+i)
        mn2 = L+i
print(sm-mn2)

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

s = 0
for i in range(n):
    s += l+(i+1)-1

cur = 10**18
temp = 0
for i in range(n):
    temp = s - (l+(i+1)-1)
    if abs(temp-s) <= cur:
        ans = temp
        cur = abs(temp-s)

print(ans)

Solution (Python):
INF = 1001001001

def resolve():
  n, l = map(int, input().split())
  base = 0
  for i in range(1, n+1):
    base += l + i - 1

  ans = 0
  sa = INF

  for i in range(1, n+1):
    tmp = base - (l + i - 1)
    if abs(base - tmp) <= sa:
      ans = tmp
      sa = abs(base - tmp)
  print(ans)
  return

if __name__ == "__main__":
  resolve()

Solution (Python):
n, l = map(int, input().split())
m = 10**10
j = 0
s = 0
for i in range(n):
    a = abs(l+i)
    s += l+i
    if a < m:
        m = a
        j = i
print(s-(l+j))

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

Solution (Python):
def main():
    N, L = (int(i) for i in input().split())
    s = sum(L + i for i in range(N))
    mi = 10**9
    ans = -1
    for i in range(N):
        eat = L + i
        if abs(eat) < mi:
            mi = abs(eat)
            ans = s - eat
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def solve():
    n,l = map(int,input().split())
    mn = 10**10
    s = 0
    for i in range(n):
        s+=l+i
        if abs(mn)>abs(l+i):
            mn = l+i
    print(s-mn)
if __name__=='__main__':
    solve()

Solution (Python):
import sys

def solve():
    input = sys.stdin.readline
    N, L = map(int, input().split())
    sumT, minT = 0, 100000000000
    pm = 0
    for i in range(N):
        sumT += L + i
        if abs(L + i) < minT:
            minT = abs(L + i)
            if L + i < 0: pm = 1
    print(sumT - minT * (-1) ** pm)
        

    return 0

if __name__ == "__main__":
    solve()

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

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

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

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

Solution (Python):
n,l = map(int, input().split())
s = float("inf")
ans = 0
for i in range(1,n+1):
    a = l+i-1
    ans += a
    if abs(a) < abs(s):
        s = a
print(ans - s)

Solution (Python):
from sys import stdin
N,L=list(map(int,stdin.readline().strip().split()))
taste=L-1
apple_list=[]
min=3000
j=0
for i in range(1,N+1):
    apple_list.append(taste+i)
    if min>abs(taste+i):
        min=abs(taste+i)
        j=i-1
apple=sum(apple_list)
print(apple-(apple_list[j]))

Solution (Python):
n,L = map(int,input().split())
taste = [0]*n
for i in range(n):
    taste[i] = L+i
taste[taste.index(min(taste, key=lambda x: abs(x)))] = 0
print(sum(taste))

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

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

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

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

a = float("inf")
v = 0
for i in range(l, l+n):
    if a > abs(i):
        v = i
        a = abs(i)

print(k - v)

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

for i in range(1, N+1):
    d=L+i-1
    if i==k:
        pass
    else:
        ans+=d
print(ans)

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

print(apple)

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

idx=taste_abs.index(min(taste_abs))
del taste[idx]
print(sum(taste))

Solution (Python):
import math
N,L = map(int,input().split())
r = []
total=0
abs_min = 100100100100
max_applepay=0
for i in range(1,N+1):
  r.append(L+i-1)
all_applepay=sum(r)
for i in range(N):
  for j in range(N):
    if j != i:
      total+=r[j]
  if abs(all_applepay-(total)) < abs_min:
    abs_min = abs(all_applepay-(total))
    max_applepay = total
  total=0
print(max_applepay)

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

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

mini = 10 ** 9
for i in range(n):
    temp = l + i
    if abs(mini) > abs(temp):mini = temp
print(taste - mini)

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

A = [L + i for i in range(N)]
A.sort(key=lambda a: abs(a))

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

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

    apples = range(L, L + N)

    ans = sum(apples)
    if apples[0] * apples[-1] <= 0:
        
        pass
    else:
        
        if apples[0] > 0:
            
            ans -= apples[0]
        else:
            
            ans -= apples[-1]
    print(ans)


if __name__ == '__main__':
    main()

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

    e = sorted((x + L for x in range(N)), key=lambda x: abs(x))
    ans = N * L + (N - 1) * N // 2 - e[0]
    print(ans)


if __name__ == '__main__':
    main()

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

Ringo = [0]*n

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

aji = sum(Ringo)
minv = 100000000000
ans = 0
for i in range(n):
    temp_aji = 0
    if i == 0:
        for j in range(1,n):
            temp_aji += Ringo[j]
    elif i == n-1:
        for j in range(n-1):
            temp_aji += Ringo[j]
    else:
        for j in range(0,i):
            temp_aji += Ringo[j]
        for j in range(i+1,n):
            temp_aji += Ringo[j]
    if abs(aji -temp_aji)  < minv:
        minv = abs(aji - temp_aji)
        ans = temp_aji
    

print(ans)

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

for i in range(1,N+1):
    A = L+i-1
    M.append(A)
    if A == 0:
        cnt += 1

B = sum(M)

if cnt == 1:
    print(B)
elif B > 0:
    print(B - min(M))
else:
    print(B - max(M))

Solution (Python):
n,l = map(int, input().split())
s = float("inf")
ans = 0
for i in range(1,n+1):
    a = l+i-1
    ans += a
    if abs(a) < abs(s):
        s = a
print(ans - s)

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

a = [(int(i)) for i in range(m, m+n)]
t=100000
ne = False
for i in range(len(a)):
    if t>abs(a[i]):
        inde = i
        t=abs(a[i])
a[inde]=0
print(sum(a))

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

s=sum(ap)
ans=100000
idx=0
for i,a in enumerate(ap):
  if abs(a)<=ans:
    ans=abs(a)
    idx=i

print(s-ap[idx])

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

A = [L + i for i in range(N)]
A.sort(key=lambda a: abs(a))

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

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

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

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

Solution (Python):
n,l = map(int, input().split())
ans = 0
m = float("inf")
for i in range(1,n+1):
    a = l + i -1
    if abs(a)<abs(m):
        m = a
    ans += a
print(ans -m)

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

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

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

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

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

all_taste = 0
taste_list = []
minimum = L + N - 1

for i in range(1, N+1, 1):
  all_taste += L + i - 1
  taste_list.append(L + i - 1)
else:
  for i in range(N):
    if abs(taste_list[i]) < abs(minimum):
      minimum = taste_list[i]
  else:
    print(all_taste - minimum)

Solution (Python):

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

taste = [l + i - 1 for i in range(1, n + 1)]
taste.sort()
ans = 1000
for i in taste:
    if abs(i) < abs(ans):
        ans = i
print(sum(taste) - ans)

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


print(sum(l)-l[l_abs.index(min(l_abs))])

Solution (Python):
n,l  =map(int,input().split())
apples = [l+i-1 for i in range(1,n+1) ]
ideal= sum(apples)
res = 10**9
for x in apples:
    v = ideal - x
    if res > abs(v-ideal):
        res = abs(v-ideal)
        ans = v

    
    

print(ans)

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

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

abs_apple = 1000
total = sum(apples)
for i in apples:
    if abs(i) < abs_apple:
        abs_apple = abs(i)
        ans = total - i

print(ans)

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

Solution (Python):
import numpy as np

def resolve():
  n, l = map(int, input().split())
  arr = []
  for i in range(n):
    arr.append(i + l)

  yotei = sum(arr)
  ans = abs(yotei - arr[0])
  sa = abs(yotei - (yotei - arr[0]))

  for i in range(n):
    if (sa > abs(yotei - (yotei - arr[i]))):
      sa = abs(yotei - (yotei - arr[i]))
      ans = yotei - arr[i]

  print(ans)

  return

if __name__ == "__main__":
  resolve()

Solution (Python):
n, l = [int(i) for i in input().split()]
ans = (l-1)*n+n*(n+1)//2
if l<=0 and l-1+n>=0:
  print(ans)
elif l+n-1<0:
  print(ans-(l+n-1))
elif l >0:
  print(ans-l)

Solution (Python):
n,l = map(int,input().split())
mn = 1000
for i in range(1,n+1):
    ans = l+i-1
    if abs(ans)<abs(mn):
        ans1 = ans
        mn = min(abs(mn),abs(ans))
ans2 = 0      
for j in range(1,n+1):
    ans2 += (l+j-1)
print(ans2-ans1)

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

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

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

eat=400
sum=0

for i in range(1,N+1):
    sum+=L+i-1
    if abs(eat)>abs(L+i-1):
        eat=L+i-1

print(sum-eat)

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

Solution (Python):
n, l = map(int, input().split())
z = 10**8
j = 0
s = 0
for i in range(n):
    s += l+i
    if abs(l+i) < z:
        z = abs(l+i)
        j = i
print(s-(l+j))

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,l = inpl()
mi = INF
a = [i+l for i in range(n)]
no = -1
for i in range(n):
    if abs(a[i]) < mi:
        no = i
        mi = abs(a[i])

print(sum(x for i,x in enumerate(a) if i != no))

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

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

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

for i in range (0, N):
	A[i] = L+i
	B[i] = abs(L+i)

min = A[B.index(min(B))]

print(sum(A)-min)

Solution (Python):
def main():
    N, L = (int(i) for i in input().split())
    s = sum(L+i-1 for i in range(1, N+1))
    mi = 10**5
    ans = -1
    for i in range(1, N+1):
        cur = L + i - 1
        eat = s - cur
        if abs(s - eat) < mi:
            mi = abs(s - eat)
            ans = eat
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
from collections import *
from heapq import *
import sys

sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]
dij = [(1, 0), (-1, 0), (0, 1), (0, -1)]


def main():
    n,l=MI()
    aa=[i+l for i in range(n)]
    print(sum(aa)-min(aa,key=lambda x:abs(x)))

main()

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

n, l = MAP()
s = (n - 1) * n // 2 + n * l
arr = []
for i in range(n):
    arr.append([l + i, abs(l + i)])
arr.sort(key=lambda x:x[1])
debug(arr)
debug(s)
print(s - arr[0][0])

Solution (Python):

N,L = map(int,input().split())
f = 0
k = 0
j = []
for i in range(1,N+1):
    f += L+i-1
for i in range(1,N+1):
    k = L+i-1
    n = f-k
    p = abs(f-n)
    j.append(p)
if f >0:
    print(int(f-min(j)))
else:
    print(int(f+min(j)))

Solution (Python):
N, L = map(int, input().split())
taste_list = list(range(L, N + L, 1))
print(sum(taste_list) - min(taste_list, key=lambda x: -x if x < 0 else x))

Solution (Python):
N,L=map(int,input().split())
lis=[]
for i in range(N):
    lis.append(L+i)
if 0 in lis:
    print(sum(lis))
else:
    lis2=sorted(lis)
    ans=sum(lis2[1:-1])
    if lis2[0]/abs(lis2[0])==-1:
        ans+=lis2[0]
    else:
        ans+=lis2[-1]
    print(ans)

Solution (Python):
def solve_131b(n, l):
    sum = 0
    min = 100000
    for i in range(1, n+1):
        sum += (l + i - 1)
    
    if l >= 0:
        min = l
    elif l + n - 1 <= 0:
        min = l + n - 1
    else:
        min = 0
    
    return sum - min

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

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

Solution (Python):
x, n = map(int, input().split())
num = []
for i in range(1, x+1):
    num.append(i+n-1)
if 0 in num:
    print(sum(num))
else:
    ma = max(num)
    mi = min(num)
    if ma < 0:
        print(sum(num)-ma)
    else:
        print(sum(num)-mi)

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

ans = 0
if l >= 0:
     for i in range(n-1):
          ans += l+i+1
elif l <= 0 <= l+n-1:
     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())
base_taste = n*l+(n*n-n)//2
if l > 0:
    print(base_taste-l)
elif n+l >= 1:
    print(base_taste)
else:
    print(base_taste-l-n+1)

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

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

Solution (Python):
import numpy as np
N, L = map(int, input().split())
taste = [L+i for i in range(N)]
if L < 0:
    print(sum(taste) + min(np.abs(taste)))
else:
    print(sum(taste) - min(np.abs(taste)))

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

Solution (Python):
import numpy as np
N,L=map(int, input().split())
taste_list = np.zeros(N)
for i in range(N):
  taste_list[i]=L+i+1-1
taste_sum = sum(taste_list) - taste_list[np.abs(taste_list)==min(np.abs(taste_list))]
print('{:.0f}'.format(taste_sum[0]))

Solution (Python):
nim, lima = map(int, input().split())
if lima<=0<=lima+nim-1:
    print(sum(range(lima,lima+nim)))
elif lima<0:
    print(sum(range(lima,lima+nim-1)))
else:
    print(sum(range(lima+1,lima+nim)))

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

sum = 0
for i in range(1,n+1):
    sum += l + i -1

if l > 0 and l+n-1 > 0:
    sum = sum - l

elif l < 0 and 0 < l+n-1:
    sum = sum - 0

elif l < 0 and l+n-1 < 0:
    sum = sum - (l+n-1)

print(sum)

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

R = L + N - 1

eat = 0
if R <= 0:
    eat = R
elif L >= 0:
    eat = L
else:
    eat = 0

ans = (R + L) * (R - L + 1) // 2 - eat
print(ans)

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

a = [L + int(x) for x in range(N)]
for i in range(len(a)):
    if a[i] < 0:
        if i == len(a)-1:
            a.pop(i)
    else:
        a.pop(i)
        break
print(sum(a))

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

deri.sort() 
if (0 in deri) == True:
    deri.remove(0) 
elif sum(deri) < 0:
    del deri[-1]
else:
    del deri[0]

deru = sum(deri)
print(deru)

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

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

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

Solution (Python):
n,l=map(int,input().split())
aji=[]
for i in range(n):
    aji.append(l+i)
apple=200
for i in range(n):
    if apple>abs(aji[i]):
        apple=abs(aji[i])
        apple_i=i
print(sum(aji)-aji[apple_i])

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

num = l + n - 1

cnt = 0
if l <= 0 and num <= 0 :
    for i in range(n - 1):
        cnt += l + i
elif l <= 0 and 0 < num:
    for i in range(n):
        cnt += l + i
else:
    for i in range(n - 1):
        cnt += l + i + 1
        
print(cnt)

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

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

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

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

n,l=MI()
tastes=[]
sche=n*(n-1)//2+n*l
dif=10**8
for i in range(1,n+1):
    taste=sche-(l+i-1)
    if abs(l+i-1)<dif:
        dif=abs(l+i-1)
        ans=taste
print(ans)

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

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

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

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

res = []
ans = 0

for i in range(N):
    res.append(L+i)
    ans += L + i

if max(res)<0:
    eaten = max(res)
elif min(res)>0:
    eaten = min(res)
else:
    eaten = 0

print(ans - eaten)

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

if Apple[0] > 0:
  B = Apple[0]

elif Apple[-1] < 0:
  B = Apple[-1]
  
else:
  B = 0
print(sum(Apple)-B)

Solution (Python):
n, l = map(int, input().split())
 
taste = []
mini = 10**9
suf = 0
for i in range(1,n+1):
    if abs(l+i-1) < mini:
        mini = abs(l+i-1)
        suf = i
    taste.append(l+i-1)
 
taste.pop(suf-1)
print(sum(taste))

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

for j in range(len(m)):
    k.append(abs(sum(m)-(sum(m)-m[j])))

for d in range(len(k)):
    if min(k)==k[d]:
        print(sum(m)-m[d])