# Arup Guha
# 12/7/2024
# Solution to Kattis Problem: Opening Ceremony

# Get number of buildings.
n = int(input())

# Read in sizes.
a = input().split()
for i in range(len(a)):
    a[i] = int(a[i])

# Sort
a.sort()

# This is the worst case.
res = n

# Try each option.
for i in range(n):
    
    # It's a[i[ horizontal zaps to get i+1 buildings, then n-1-i vertical ones...
    tmp = a[i] + n-1-i
    res = min(res, tmp)

# Ta da!
print(res)
