K = 100

n = gets.chomp.to_i
h = gets.chomp.split(' ').map(&:to_i)

a = [nil] * K
K.times do |i|
  a[i] = [0] * n
end

h.each_with_index do |v, i|
  (0...v).each do |j|
    a[j][i] = 1
  end
end

def count(v)
  c = 0
  p = 0
  v.size.times do |i|
    if p == 0 && v[i] == 1 then
      c += 1
    end
    p = v[i]
  end
  return c
end

s = 0
K.times do |i|
  s += count(a[i])
end
puts s.to_s