#include<iostream>
using namespace std;
int main(){
    long long n, otg = 0;
    cin >> n;
    long long boxes[n];
    for(int i = 0; i < n; i++){
        cin >> boxes[i];
    }
    for(int i = 0; i < n; i++){
        int closestTo, closestToIndex;
        closestTo = 0;
        for(int j = 0; j < n; j++){
            if(j != i){
                if(boxes[j] > closestTo && boxes[j] < boxes[i]){
                    closestTo = boxes[j];
                    closestToIndex = j;
                }
            }
        }
        boxes[closestToIndex] = 0;
    }
    for(int i = 0; i < n; i++){
        otg += boxes[i];
    }
    cout << otg;
    return 0;
}
