Chef has an array of N integers. He wants to play a special game. In this game he needs to make all the integers in the array greater than or equal to 0. 
Chef can use two types of operations. The first type is to  increase all the integers of the given array by 1, but it costs X coins. The operation of the second type is to add 1 to only one integer of the given array and to use this operation you need to pay 1 coin. You need to calculate the minimal cost to win this game (to make all integers greater than or equal to 0)  

-----Input-----

The first line of the input contains an integer N denoting the number of elements in the given array. The second line contains N space-separated integers A1, A2, ..., AN denoting the given array. The third line contains number X - cost of the first type operation. 


-----Output-----
For each test case, output a single line containing minimal cost required to make all the integers greater than or equal to zero.

-----Constraints-----

- 1 ≤ N ≤ 105
- -109 ≤ Ai ≤  109 
- 0 ≤ X  ≤ 109

-----Example-----
Input:
3
-1 -2 -3
2

Output:
5

-----Explanation-----
Example case 1: Use the first type operation twice and the second type once.

Difficulty: interview

Starter code:

Solutions:
n=int(input())
a=list(map(int,input().split()))
x=int(input())
l=[]
for i in a:
 if i<0:
  l.append(-i)
l.sort()
m=len(l)
ans=0
if l:
 if x>n:
  ans=sum(l)
 else:
  ans=sum(l[m-x:])
print(ans)

 


# cook your dish here
n=int(input())
k=n+1
total=0
a=list(map(int,input().split()))
x=int(input())
a.sort(reverse=True)
for i in range(n):
 if a[i]<0:
  k=i
  break
a=a[k:]
if a:
 n=len(a)
 if x>n:
  total-=sum(a) 
 else:
  total-=sum(a[n-x:])
print(total)

# cook your dish here
n=int(input())
k=n+1
total=0
a=list(map(int,input().split()))
x=int(input())
a.sort(reverse=True)
for i in range(n):
 if a[i]<0:
  k=i
  break
a=a[k:]
if a:
 n=len(a)
 if x>n:
  total-=sum(a) 
 else:
  total-=sum(a[n-x:])
print(total)

n = int(input())
a = list(map(int, input().split(" ")))
x = int(input())
a.sort()
ans = 0
if x == 0:
 ans = 0
elif x < n:
 op1 = max(0, -a[x - 1])
 ans += op1 * x
 for i in range(x - 1):
  ans += max(0, -(a[i] + op1))
else:
 for i in range(n):
  if a[i] < 0:
   ans += -a[i]
   
print(ans)

from sys import stdin


def solve():
 n = int(stdin.readline())
 a = list(map(int, stdin.readline().split()))
 x = int(stdin.readline())
 a.sort()
 ans = 0
 if x == 0:
  ans = 0
 elif x < n:
  op1 = max(0, -a[x - 1])
  ans += op1 * x
  for i in range(x - 1):
   ans += max(0, -(a[i] + op1))
 else:
  for i in range(n):
   if a[i] < 0:
    ans += -a[i]
 print(ans)


def __starting_point():
 solve()

__starting_point()


n = int(input())
a = list(map(int,input().split()))
x = int(input())
l1 = [i for i in a if i<0]
l1.sort()
l1.reverse()
if(len(l1)>x and x>0):
 i = len(l1)-x
 l2 = l1[0:i]
 l1 = l1[i:]
 cnt1 = abs(sum(l2))*x-abs(sum(l2[0:i-1])*x)
 cnt2 = abs(sum(l1))-((cnt1//x)*len(l1))
 cnt = cnt1+cnt2
 print(cnt)
elif(x==0):
 print(0)
else:
 print(abs(sum(l1)))

n=int(input())
arr=list(map(int, input().split()))
x=int(input())
l=[]
for i in arr:
 if i<0:
  l.append(i)
l.sort(reverse=True)
s=0
inc=0
z=len(l)
for i in range(len(l)):
 if x<=z:
  l[i]+=inc
  s+=abs(l[i])*x
  inc+=abs(l[i])
  z-=1
 else:
  l[i]+=inc
  s+=abs(l[i])
print(s)


n=int(input())
l=[int(i) for i in input().split()]
x=int(input())
l.sort()
if(l[0]>=0):
 print(0)
else:
  cnt = 0
  cost = 0
  for i in l:
   if(i<0):
    cnt+=1
   else:
    break
  l = l[0:cnt]
  if(x>=len(l)):
   print(sum(l)*-1)
  else:
   k = min(l[x:len(l)])
   cost+=-1*k*x
   tmp = l[0:x]
   tmp = [i-k for i in tmp]
   for i in tmp:
    cost+= max(0,-1*i)
   print(cost)

# cook your dish here
n=int(input())
l=[int(i) for i in input().split()]
x=int(input())
l.sort()
if(l[0]>=0):
 print(0)
else:
  cnt = 0
  cost = 0
  for i in l:
   if(i<0):
    cnt+=1
   else:
    break
  l = l[0:cnt]
  if(x>=len(l)):
   print(sum(l)*-1)
  else:
   k = min(l[x:len(l)])
   cost+=-1*k*x
   tmp = l[0:x]
   tmp = [i-k for i in tmp]
   for i in tmp:
    cost+= max(0,-1*i)
   print(cost)


# cook your dish here
n=int(input())
l=[int(i) for i in input().split()]
x=int(input())
l.sort()
if(l[0]>=0):
 print(0)
else:
  cnt = 0
  cost = 0
  for i in l:
   if(i<0):
    cnt+=1
   else:
    break
  l = l[0:cnt]
  if(x>=len(l)):
   print(sum(l)*-1)
  else:
   k = min(l[x:len(l)])
   cost+=-1*k*x
   tmp = l[0:x]
   tmp = [i-k for i in tmp]
   for i in tmp:
    cost+= max(0,-1*i)
   print(cost)


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

k=[]
for i in l:
 if i<0:
  k.append(i)

c=len(k)
ans=0
if c>=x:
 if x==0:
  print(0)
 else:
  k.sort()
  m = k[x-1]
  ans+=-1*m*x
  for j in range(len(k)):
   k[j]+=-1*m
  for j in k:
   if j<0:
    ans+=-1*j
  print(ans)
 
else:
 ans+=-1*sum(k)
 print(ans)


n=int(input())
arr=list(map(int, input().split()))
x=int(input())
l=[]
for i in arr:
 if i<0:
  l.append(i)
l.sort(reverse=True)
s=0
inc=0
z=len(l)
for i in range(len(l)):
 if x<=z:
  l[i]+=inc
  s+=abs(l[i])*x
  inc+=abs(l[i])
  z-=1
 else:
  l[i]+=inc
  s+=abs(l[i])
print(s)

n = int(input())
a = [int(x) for x in input().split()]
x = int(input())
l = []
c = 0

for i in range(n):
 if a[i] < 0:
  l.append(-a[i])
l.sort()
ll = len(l)
num = ll - x

ans = 0
for i in range(len(l)):
 l[i] = c - l[i]
 if ll > x:
  ans += abs(l[i] * x)
  c += abs(l[i])
 else:
  ans += abs(l[i] * ll)
  c += abs(l[i])
 ll -= 1
 
print(ans)



n = int(input())
a = list(map(int,input().split()))
x = int(input())
l1 = [i for i in a if i<0]
l1.sort()
l1.reverse()
if(len(l1)>x and x>0):
 i = len(l1)-x
 l2 = l1[0:i]
 l1 = l1[i:]
 cnt1 = abs(sum(l2))*x-abs(sum(l2[0:i-1])*x)
 cnt2 = abs(sum(l1))-((cnt1//x)*len(l1))
 cnt = cnt1+cnt2
 print(cnt)
elif(x==0):
 print(0)
else:
 print(abs(sum(l1)))

def pos(lst):
 return [x for x in lst if x < 0]
N=int(input())
List1=[int(x) for x in input().split()]
X=int(input())
Sum=0
List=pos(List1)
List.sort()
if(len(List)>X):
 Sum+=(-1*List[X])*X
 for i in range(X):
  Sum+=(-1*List[i])+List[X]
else:
 Sum+=(-1*sum(List))
print(Sum)
  


# cook your dish here

n = int(input())

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

x = int(input())

count = 0
k = []
for i in range(n):
 if l[i] <0:
  count+=1
  k.append(l[i])

y = count
k.sort()


z = y-x
k.reverse()
sum = 0
h = 0

for i in range(len(k)):
  k[i]+=h
  if y > x:


   sum+=abs(k[i]*x)
   h+=abs(k[i])
  else:
   sum+=abs(k[i]*y)
   h+=abs(k[i])

  y-=1

 # k[-1]+=h
 # if k[-1]<0:
 #     sum+=abs(k[-1])*y
print(sum)



n=int(input())
list_int=[int(i) for i in input().split()]
x=int(input())

def Negative(List):
 return [num for num in List if num<0]
l = Negative(list_int)
l.sort()
list_sum = sum(l)

if(x==0):
 print(0)
elif(x==1):
 print(-l[0])
elif(x<len(l)):
 #cost=0
 #cost1 = -l[x]*x
 #cost2 = -(sum(l[:(x)])-l[x]*x)
 #cost  = cost1+cost2
 cost = -(sum(l[:(x)]))
 print(cost)
else:
 cost = -(list_sum)
 print(cost)

n=int(input())
list_int=[int(i) for i in input().split()]
x=int(input())

def Negative(List):
 return [num for num in List if num<0]
l = Negative(list_int)
l.sort()
list_sum = sum(l)

if(x==0):
 print(0)
elif(x==1):
 print(-l[0])
elif(x<len(l)):
 cost=0
 cost1 = -l[x]*x
 cost2 = -(sum(l[:(x)])+ cost1)
 cost = cost1+cost2
 print(cost)
else:
 cost = -(list_sum)
 print(cost)

#print('hare krishna')
n=int(input())
l=[int(i) for i in input().split()]
x=int(input())
l1=sorted([i for i in l if i<0])
k=sum(i<0 for i in l)
if k<=x:
 print(-sum(i for i in l if i<0))
else:
 # print(l1)
 elem=-(l1[x-1])
 #print(elem)
 ans=elem*x 
 for i in range(x-1):
  ans+=(abs(l1[i])-elem)
 print(ans)


n=int(input())
a=[int(i) for i in input().split() if int(i)<0]
x=int(input())

a.sort(reverse=True)
na=len(a)
if x==0:
 print(0)
elif x<=na:
 c=na-x
 print(-a[c]*x+sum([a[c]-i for i in a[c+1:]]))
else:
 print(-sum(a))

N=int(input())
A=list([x for x in map(int,input().split()) if x<0])
X=int(input())
coins=0
if(len(A)<=X):
 coins+=abs(sum(A))
else:
 A.sort(reverse=True)
 coins=abs(sum(A[len(A)-X:]))
print(coins)