AlgoUniversity
  • Go Back
Discussion
Research Lab :

Author

Akshay Sharma

Difficulty Level : Easy

Submissions : 1405

Asked In : Wells-Fargo

Marks :100

: 7 | : 1

In a science research lab, combining two nuclear chemicals produces a maximum energy that is the product of the energy of the two chemicals. The energy values of the chemicals can be negative or positive. The scientist wishes to calculate the sum of the energies of the two chemicals which produces maximum energy on reaction.

Write an algorithm to find the sum of energy of the two chemicals which produces maximum energy on reaction.

Input

The first line of the input consists of an integer - numrChem, representing the number of chemicals (N). ($$$0 \le numOfChem \le 10^6$$$)

The second line consists of N space-separated integers- ener*0*, ener*1* ....... ener*N-1* representing the energies of the chemicals.($$$-10^6 \le eneri \le 10^6$$$)

Output

Print an integer representing the sum of energy of the two chemicals which produces maximum energy on reaction

Example

Input
7
9 -3 8 -6 -7 8 10
Output
19

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.