| 12 | using namespace std; |
| 13 | |
| 14 | main() { |
| 15 | int t; |
| 16 | cin>>t; |
| 17 | while(t--) |
| 18 | { |
| 19 | //Taking inputs |
| 20 | int n; |
| 21 | cin>>n; |
| 22 | int a[n]; |
| 23 | for(int i=0;i<n;i++) |
| 24 | cin>>a[i]; |
| 25 | //Inputs have been taken |
| 26 | sort(a,a+n,greater<int>()); //We sort the array in descending order to get the maximum profit cars first |
| 27 | int res = 0; |
| 28 | for(int i=0;i<n;i++) |
| 29 | { |
| 30 | res += max(a[i]-i, (int) 0); //A simple loop that sells the cars one by one, we either take the deprecated value of |
| 31 | } //the car or we take the price to be 0, since it cannot deprecate beyond 0. |
| 32 | res = res%1000000007; //The result is operated upon a modulo 10^9 + 7 |
| 33 | cout<<res<<endl; |
| 34 | } |
| 35 | return 0; |
| 36 | } |