s = getter = -> {
   require 'stringio'
  _in = StringIO.new
  while l = gets
    _in << l
  end
  _in.string
}.call.split(/\R/)
n,l = s[0].split(/ /)
_p = s[1].split(/ /).map(&:to_i)

puts _p.min(3).sum