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();
        int result = 0;
        while (numbers.Count > 1) 
        {
            int avg = (numbers.Max() + numbers.Min()) / 2;
            for (int i = 0; i < numbers.Count; i++)
            {
                if (numbers[i] > avg)
                {
                    result += numbers[i];
                    for (int a = 0; a < numbers.Count; a++)
                    {
                        if (a < i)
                        {
                            if (!(numbers[a] == numbers[i]))
                            {
                                numbers[a]--;
                                if (numbers[a] == 0)
                                    numbers.RemoveAt(a);
                            }
                        }
                        else if (a > i) 
                        {
                            if (!(numbers[a] == numbers[i]))
                                numbers[a]++;
                        }
                    }
                    numbers.RemoveAt(i);
                    break;
                }
            }
        }
        result += numbers[0];
        Console.WriteLine(result);
  }
}
