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

int n;
int[] a;
int c = 0;

n = int.Parse(Console.ReadLine());
a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

Dictionary<int, int> boxes = new Dictionary<int, int>();
for (int i = 0; i < a.Length; i++)
{
    if (boxes.ContainsKey(a[i]))
    {
        boxes[a[i]] += 1;
    }
    else
    {
        boxes[a[i]] = 1;
    }
}

void @do()
{
    int max_ = boxes.Keys.Max();
    int count = boxes[max_];
    c += count * max_;
    boxes.Remove(max_);
    var tmp = boxes.ToDictionary(x => x.Key - count, x => x.Value);
    boxes = tmp;
}

while (boxes.Count > 0)
{
    @do();
    if (boxes.ContainsKey(1))
    {
        boxes.Remove(1);
    }
}

Console.WriteLine(c);