Increment- Decrement Philosophy (Contest)
Increment- Decrement Philosophy (Contest) easy Time Limit: 2 sec Memory Limit: 128000 kB
PreviousHip Hip Array (Contest)NextInfinity Stones : Form Black Order - The Army of Thanos (Contest)
Last updated
Increment- Decrement Philosophy (Contest) easy Time Limit: 2 sec Memory Limit: 128000 kB
Last updated
Problem Statement :
You are given an array A of size N (1 - indexed). In one move, you can choose any two indices i, j such that Ai > Aj. Now, you can decrease Ai by 1 and increase Aj by 1. Find out the maximum possible value of A1 after any number of moves. Input The first line of the input contains a single integer N. The second line of the input contains N space seperated integers.
Constraints: 1 <= N <= 105 1 <= Ai <= 109 Output Print the maximum possible value of A1 after any number of moves. Example Sample Input: 3 1 2 3
Sample Output: 3
link: