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