using System;

class Solution {
  public static void Main(string[] args) {
      bool isless(long[] mas)
            {
                for(int i = 0; i < mas.Length; i++)
                {
                    if (mas[i] > 0) return false;
                }
                return true;
            }
            void minus(ref long[] mas, long mi)
            {
                for(int i = 0; i < mas.Length; i++)
                {
                    mas[i] -= mi;
                }
            }
            int n = int.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split(' ');
            long[] a = new long[n];
            long price = 0;
            for(int i = 0; i < s.Length; i++)
            {
                a[i] = long.Parse(s[i]);
            }
            Array.Sort(a);
            long max = a[n - 1], nn=0;
            while (!isless(a))
            {
                while (a[n - 1] == max)
                {
                    price += a[n - 1];
                    a[n - 1] = 0;
                    Array.Sort(a);
                    nn++;
                }
                max = a[n - 1];
                minus(ref a, nn);
                nn = 0;
            }
            Console.WriteLine(price);
            Console.ReadKey();
  }
}
