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;
        for (int i = 0; i < numbers.Count; i++)
        {
            if (numbers[i] == temp)
            {
                result += (numbers[i]-c)+1;
                c++;
            }
            else
            {
                result += numbers[i] - c;
                c++;
            }
            temp = numbers[i];
        }
        Console.WriteLine(result);
  }
}
