Mouche Goldberg starts trading in N towns (numbered 1 to N) . Everyday he sells his products in one of the towns. The towns that are chosen on any two successive days should be different and a town i can be chosen at most ci times.
Write an algorithm to determine the number of days when he can operate following the above mentioned rules.
for eg.
N=3
7,2,3
Output =11