import java.util.Arrays;
import java.util.Scanner;
import java.util.SortedMap;

public class Main {


    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n+1];
        for (int i = 1; i <= n; i++) {
            a[sc.nextInt()]++ ;
        }
        long count = 0;
        int lastIndex = n;
        while (isEmpty(a)){
            count += lastIndex;
            a[lastIndex]-=1;
            for (int i = 1; i < lastIndex; i++) {
                a[i-1] = a[i];
                a[i] = 0;
            }
            a[0] = 0;
            if (a[lastIndex]<=0){
                for (int i = n; i >= 0; i--) {
                    if (a[i]>0){
                        lastIndex = i;
                        break;
                    }
                }
            }
        }
        System.out.println(count);
    }

    private boolean isEmpty(int[] a) {
        for (int i = 1; i < a.length; i++) {
            if (a[i]!=0)return true;
        }
        return false;
    }
}




















