Vote for Patil!!

5

1 votes
Very-Easy
Problem

The atmosphere in VNIT is full of excitement due to the forthcoming elections for the General Secretary. The new reformed rules for the elections state that :
1: A department is said to be in favour of a candidate if atleast more than half of the students of a department vote for him.
2: The candidate is declared as winner if more than half the departments are in his favour.
This year Patil, from the Department of Computer Science is contesting these prestigious elections.
Having given the number of departments and number of students in each department, find for him the minimum number of students from VNIT that must vote for him to guarantee his victory.
Input:
In the first line an integer K denoting quantity of departments is written. In the second line there are written K integers, separated with a space. Those numbers define number of students in each department.
Output:
You should write the minimum number of students, that can make him the General Secretary.
Constraints:
1 ≤ K ≤ 101 The number of students in college does not exceed 9999.

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

For a majority,he needs to win over 2 of the 3 departments.Now to win over 2 departments the minimum number of students required would be 4 for the 1st department plus 3 for the 3rd department .Hence the answer 7.

Editor Image

?