import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
class Main {
  public static void main(String[] args) throws IOException{
    BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    String[] NK = bf.readLine().split(" ");
    int N = Integer.parseInt(NK[0]);
    int K = Integer.parseInt(NK[1]);
    String[] P = bf.readLine().split(" ");
    List<Integer> l = new ArrayList<Integer>();
    for (String s : P ) {
      l.add(Integer.parseInt(s));
    }
    l.sort(Comparator.naturalOrder());

    int sum = 0;
    for (int i = 0 ; i < K; i++) {
      sum = sum + l.get(i);
    }
    System.out.println(sum);
  }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayList; ArrayList java.util import java.util.Comparator; Comparator java.util import java.util.List; List java.util class Main {
  public static void main(String[] args) throws IOException{
    BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    String[] NK = bf.readLine().split(" ");
    int N = Integer.parseInt(NK[0]);
    int K = Integer.parseInt(NK[1]);
    String[] P = bf.readLine().split(" ");
    List<Integer> l = new ArrayList<Integer>();
    for (String s : P ) {
      l.add(Integer.parseInt(s));
    }
    l.sort(Comparator.naturalOrder());

    int sum = 0;
    for (int i = 0 ; i < K; i++) {
      sum = sum + l.get(i);
    }
    System.out.println(sum);
  }
} Main public static void main(String[] args) throws IOException{
    BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    String[] NK = bf.readLine().split(" ");
    int N = Integer.parseInt(NK[0]);
    int K = Integer.parseInt(NK[1]);
    String[] P = bf.readLine().split(" ");
    List<Integer> l = new ArrayList<Integer>();
    for (String s : P ) {
      l.add(Integer.parseInt(s));
    }
    l.sort(Comparator.naturalOrder());

    int sum = 0;
    for (int i = 0 ; i < K; i++) {
      sum = sum + l.get(i);
    }
    System.out.println(sum);
  } main {
    BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    String[] NK = bf.readLine().split(" ");
    int N = Integer.parseInt(NK[0]);
    int K = Integer.parseInt(NK[1]);
    String[] P = bf.readLine().split(" ");
    List<Integer> l = new ArrayList<Integer>();
    for (String s : P ) {
      l.add(Integer.parseInt(s));
    }
    l.sort(Comparator.naturalOrder());

    int sum = 0;
    for (int i = 0 ; i < K; i++) {
      sum = sum + l.get(i);
    }
    System.out.println(sum);
  } BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); bf new BufferedReader(new InputStreamReader(System.in)) String[] NK = bf.readLine().split(" "); NK bf.readLine().split(" ") bf.readLine().split bf.readLine() bf.readLine bf " " int N = Integer.parseInt(NK[0]); N Integer.parseInt(NK[0]) Integer.parseInt Integer NK[0] NK 0 int K = Integer.parseInt(NK[1]); K Integer.parseInt(NK[1]) Integer.parseInt Integer NK[1] NK 1 String[] P = bf.readLine().split(" "); P bf.readLine().split(" ") bf.readLine().split bf.readLine() bf.readLine bf " " List<Integer> l = new ArrayList<Integer>(); l new ArrayList<Integer>() for (String s : P ) {
      l.add(Integer.parseInt(s));
    } String s P {
      l.add(Integer.parseInt(s));
    } {
      l.add(Integer.parseInt(s));
    } l.add(Integer.parseInt(s)) l.add l Integer.parseInt(s) Integer.parseInt Integer s l.sort(Comparator.naturalOrder()) l.sort l Comparator.naturalOrder() Comparator.naturalOrder Comparator int sum = 0; sum 0 for (int i = 0 ; i < K; i++) {
      sum = sum + l.get(i);
    } int i = 0 ; int i = 0 ; i 0 i < K i K i++ i++ i {
      sum = sum + l.get(i);
    } {
      sum = sum + l.get(i);
    } sum = sum + l.get(i) sum sum + l.get(i) sum l.get(i) l.get l i System.out.println(sum) System.out.println System.out System System.out sum String[] args args
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
class Main {
  public static void main(String[] args) throws IOException{
    BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    String[] NK = bf.readLine().split(" ");
    int N = Integer.parseInt(NK[0]);
    int K = Integer.parseInt(NK[1]);
    String[] P = bf.readLine().split(" ");
    List<Integer> l = new ArrayList<Integer>();
    for (String s : P ) {
      l.add(Integer.parseInt(s));
    }
    l.sort(Comparator.naturalOrder());

    int sum = 0;
    for (int i = 0 ; i < K; i++) {
      sum = sum + l.get(i);
    }
    System.out.println(sum);
  }
}