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

class Program
{
    static Dictionary<int, int> boxes = new Dictionary<int, int>();
    static int c = 0;
    static int[] a;
    static int n;


    static void Main(string[] args)
    {
        n = int.Parse(Console.ReadLine());
        a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        c = 0;

        for (int i = 0; i < n; i++)
        {
            if (boxes.ContainsKey(a[i]))
            {
                boxes[a[i]] += 1;
            }
            else
            {
                boxes[a[i]] = 1;
            }
        }

        while (boxes.Count > 1)
        {
            int last = boxes.Keys.Max();
            c += last;
            change(last);
        }
        Console.WriteLine(c);
    }

    static void change(int i)
    {
        Dictionary<int, int> tmp = new Dictionary<int, int>();
        foreach (var j in boxes)
        {
            if (j.Key > i)
            {
                tmp[j.Key + 1] = j.Value;
            }
            else if (j.Key < i)
            {
                tmp[j.Key - 1] = j.Value;
            }
        }
        foreach (var j in boxes)
        {
            if (j.Key == i)
            {
                tmp[j.Key] = j.Value - 1;
                if (tmp[j.Key] == 0)
                {
                    tmp.Remove(j.Key);
                }
            }
        }
        boxes = tmp;
    }
}