Chef and Integers

All submissions for this problem are available.
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 spaceseparated integers A_{1}, A_{2}, ..., A_{N} 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 ≤ 10^{5}
 10^{9} ≤ A_{i} ≤ 10^{9}
 0 ≤ X ≤ 10^{9}
Example
Input: 3 1 2 3 2 Output: 5
Explanation
Example case 1: Use the first type operation twice and the second type once.
Author:  furko 
Tester:  xcwgf666 
Editorial  http://discuss.codechef.com/problems/INTEG 
Tags  furko, sept13, simple 
Date Added:  18062013 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, PYP3, CLOJ, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 