AlgoUniversity
  • Go Back
Discussion
Efficient Teams :

Author

Shikhar Mehrotra

Difficulty Level : Easy

Submissions : 95

Asked In : AMD

Marks :20

: 0 | : 0

There are $$$N$$$ candidates with skills as $$$skill[i]$$$ denoting skill of $$$i_{th}$$$ candidate.

A total of $$$N/2$$$ teams are to be formed with 2 people each and no person can be in the same team as well as each person has to be in some team. and also sum of skills of team members in each team should be same

Then efficiency of team is defined as product of skills of team members. Your task is to find the efficiency of formed teams which is sum of efficiency of each team. If $$$N/2$$$ teams cannot be formed as per above condition then output -1.

Input

The first line contains a single integer $$$1\le N \le 10^{5}$$$. The second line contains $$$N$$$ space separated integers denoting the $$$skill$$$ array where $$$i_{th}$$$ integer represent $$$1\le skill[i] \le 10^{5}$$$ denoting skill of $$$i_{th}$$$ candidate.

Output

Output sum of efficiency of valid team formation or output -1 if valid team formation is not possible.

Examples

Input
6
2 1 1 4 3 4
Output
14
Input
4
5 4 2 1
Output
13
Input
5
2 1 4 3 5
Output
-1

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.