from sys import stdin, stdout
read = stdin.readline
write = stdout.write
flush = stdout.flush
xr = range

def main():
  n,k = map(int,read().split())
  a = sorted(list(map(int,read().split())))
  write('{}\n'.format(sum(a[:k])))

if __name__ == "__main__":
  main()