using System.IO; namespace ttt { internal class Program { static void Main(string[] args) { int max = 50; int n = int.Parse(Console.ReadLine()); string input = Console.ReadLine(); int[] nums = input.Split(' ').Select(int.Parse).ToArray(); int[] count = new int[max + 1]; int total = 0; foreach (int i in nums) count[i]++; for (int i = max; i > 0; i--) while (count[i] > 1) { for (int j = i + 1; j <= max; j++) if (count[j] == 0) { count[j] = 1; count[i]--; total++; break; } } Console.WriteLine(total); } } }