n = gets.to_i
a = $<.map(&:to_i).sort.reverse

def f(a, select = [])
	max = select.flatten.max || 0
	if a.empty?
		return max
	end
	
	k = a[0]
	ans = []
	[k, select.size].min.downto(1){|r|
		(1..max).to_a.combination(r){|b|
			if check(select, b)			
				ans << f(a[1..-1], select + [b + (max+1..max+k-r).to_a])
			end
		}
	}
	ans << f(a[1..-1], select + [(max+1..max+k).to_a])
	ans.min
end

def check(select, a)
	select.all?{|b| (b & a).size <= 1}
end

s = 0
(0..n-1).each{|i|
	if a[i] > n-1
		s += a[i]-n+1
		a[i] = n-1
	end
}
p s + f(a, [])