
ZOJ Problem Set  3631
Watashi is the couch of ZJUICPC Team and he is very kind hearted. In ZJUICPC summer training camp, students are divided into several groups and each day one of the groups will design some problems to hold a contest. Today students of Group C are required to design the problems, and they spent the whole night to check to test data which made them very tired. Watashi decides to give some money as a reward to group C so that they can buy the lunch for free. There are N days in the training schedule, and all students have booked their lunch for N days so we know how much money they will spend in each day. Now the leader of group C needs to decide how to use Watashi's money. Since the money is limited, it may not be possible that they can have free lunch every day. So each day the leader can choose to pay for the whole group's lunch by themselves or use Watashi's money. Of course, the leader wants to spend Watashi's money as much as possible, but he is too busy to write a program to calculate the maximum money he can spend from Watashi's reward. Can you help him? Input
The input contains multiple test cases ( no more than 50 test cases ). OutputFor each test case, output one line with an integer which is the maximum money group C can spend from Watashi's reward Sample Input3 10 8 4 5 Sample Output9 Author: HUANG, Qiao Contest: ZOJ Monthly, July 2012 