An employee in an organization has begun working on N projects (numbered 0 to N-1). Each week he/she can work on a single module of one of the projects. The modules that are chosen on any two successive weeks should come from different projects. A project i can have at most Ci modules. The modules of the projects are such that a module is completed in a week.
Write an algorithm to determine the number of weeks the employee can work on projects following the above-mentioned rules.
The first line of the input consists of an integer - num, representing the number of projects (N). The next line consists of N space-separated integers - projC0, projC1,..., projCN-1, representing the number of modules of the projects.
Print an integer representing the maximum number of weeks the employee can work on the projects.