#K68162. Minimum Operations to Make Array Elements Non-negative

    ID: 32804 Type: Default 1000ms 256MiB

Minimum Operations to Make Array Elements Non-negative

Minimum Operations to Make Array Elements Non-negative

You are given an array of n integers. The goal is to determine the minimum number of operations required to make every element in the array non-negative. In one operation, you can increase a single element by 1. Essentially, for each negative element, you will need to perform an operation for each unit required to bring it to zero.

Mathematically, if the array is a where ai < 0, then the answer is given by:

\(\sum_{a_i < 0} |a_i|\)

For example, for an array [-1, -2, -3, 4, 5], the minimum required operations is \(1 + 2 + 3 = 6\).

inputFormat

The input is read from standard input (stdin) in the following format:

  1. The first line contains an integer n representing the number of elements in the array.
  2. The second line contains n space-separated integers representing the elements of the array.

outputFormat

Output to standard output (stdout) a single integer which is the minimum number of operations required to make all the array elements non-negative.

## sample
5
-1 -2 -3 4 5
6