use strict;
use Statistics::Lite qw(sum);
my($n,$k)=glob <>;
chomp $n;
chomp $k;
my $x = <>;
chomp $x;
my @a = split(' ',$x);
@a = sort {$a <=> $b} @a;
my @b = splice @a, 1, $k;
my $sum = sum @b;
print "$sum";