using System;
using System.Collections.Generic;
using System.Linq;

class Solution {
  public static void Main(string[] args) {
int n = Convert.ToInt32(Console.ReadLine());
        List<int> numbers = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse).ToList();
        numbers.Sort();
        numbers.Reverse();
        int result = 0;
        int temp = 0;
        int c = 0;
        HashSet<int> luni = numbers.ToHashSet();
        int r = numbers.Count - luni.Count;
        for (int i = 0; i < numbers.Count; i++)
        {
            if (numbers[i] - c > 0) 
            {
                result += numbers[i] - c;
                c++;
            }
        }
        Console.WriteLine(result+r);
  }
}
