AlgoUniversity
  • Go Back
Discussion
Medical Centers :

Author

Akshay Sharma

Difficulty Level : Easy

Submissions : 606

Asked In : Flipkart

Marks :100

: 11 | : 1

The Health Ministry of Torris county has decided to set up medical centres for the benefit of its citizens. The Ministry selects N different cities in the county in which to establish a medical centre.

Each city is identified by a city ID ranging from 0 to N 1. Multiple medical centres are needed in different cities according to requirements. Each day a medical centre will be set up in one of the selected cities. On any two consecutive days, the chosen city must be different.

Write an algorithm to determine the maximum number of medical centres that will be set up in the county covering the maximum number of locations.

Input

The first line of the input consists of an integer - numCity representing the number of cities selected for a medical centre (N).($$$1 \le N \le 10^4$$$) The next line consists of N space-separated integers - loc*1*, loc*2*,.. loc*N* representing the number of locations to set up a medical center in a city ($$$1 \le loc[i] \le 10^5$$$).

Output

Print an integer representing the maximum number of medical centres that will be set up in the county covering the maximum number of locations.

Example

Input
3
11 5 4
Output
19

Note

In reference to test case 1 :

The first, second and third cities are selected with locations 11, 4 and 5, respectively.

The locations of different cities are selected on successive days in a sequence:

1st, 2nd, 1st, 3rd, 1st, 2nd, 1st, 3rd,1st, 2nd, 1st, 3rd, 1st, 2nd, 1st, 3rd, 1st, 3rd, 1st

So, the maximum number of medical centres that may be set up in the county is 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.