#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
    // Fast I/O
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    if (!(cin >> n)) return 0;

    vector<int> arr(n);
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }

    int k;
    cin >> k;

    // Step 1: Sort in descending order to pick the largest happiness first
    sort(arr.rbegin(), arr.rend());

    ll totalHappiness = 0;

    // Step 2: Select top k children while accounting for the turn penalty
    for (int i = 0; i < k; i++) {
        ll effectiveHappiness = arr[i] - i;

        // If effective happiness becomes 0 or negative, remaining items won't add any value
        if (effectiveHappiness <= 0) {
            break;
        }

        totalHappiness += effectiveHappiness;
    }

    cout << "Maximum Happiness : " << totalHappiness << "\n";

    return 0;
}