C++ easy to understand solution
\nint fillCups(vector<int>& amount) {\n        int n=amount.size();\n        sort(amount.begin(),amount.end());\n        int cnt=0;\n        while(amount[1]!=0)
```\nint fillCups(vector<int>& amount) {\n        int n=amount.size();\n        sort(amount.begin(),amount.end());\n        int cnt=0;\n        while(amount[1]!=0){\n            amount[1]--;\n            amount[2]--;\n            cnt++;\n            sort(amount.begin(),amount.end());\n        }\n        cnt+=amount[2];\n        return cnt;\n    }\n\t```\nSort the array then run the loop while the middle element of the array is not equal to 0 because then it wouldn\'t be able to make pairs with greater elements.\nEvery time the loop runs just subtract second highest and highest element by one when middle element becomes zero add the largest element to count variable. Don\'t forget to sort the array after each iteration of while loop.
['C', 'Sorting']