import java.util.List;
import java.util.Scanner;
import java.util.Arrays;
public class Main {
	public static void main(String[] args) {
        Scanner sn = new Scanner(System.in);
        int cnt = Integer.parseInt(sn.next());
        int y = Integer.parseInt(sn.next());
        int[] list = new int[cnt];
        int sum = 0;
        for ( int i = 0; i < cnt ; i++){
            list[i] = Integer.parseInt(sn.next());
        }
        Arrays.sort(list);
        for ( int l = 0; l < y ; l++){
            sum = sum + list[l];
        }
        System.out.println(sum);
	}
}
 import java.util.List; List java.util import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util public class Main {
	public static void main(String[] args) {
        Scanner sn = new Scanner(System.in);
        int cnt = Integer.parseInt(sn.next());
        int y = Integer.parseInt(sn.next());
        int[] list = new int[cnt];
        int sum = 0;
        for ( int i = 0; i < cnt ; i++){
            list[i] = Integer.parseInt(sn.next());
        }
        Arrays.sort(list);
        for ( int l = 0; l < y ; l++){
            sum = sum + list[l];
        }
        System.out.println(sum);
	}
} Main public static void main(String[] args) {
        Scanner sn = new Scanner(System.in);
        int cnt = Integer.parseInt(sn.next());
        int y = Integer.parseInt(sn.next());
        int[] list = new int[cnt];
        int sum = 0;
        for ( int i = 0; i < cnt ; i++){
            list[i] = Integer.parseInt(sn.next());
        }
        Arrays.sort(list);
        for ( int l = 0; l < y ; l++){
            sum = sum + list[l];
        }
        System.out.println(sum);
	} main {
        Scanner sn = new Scanner(System.in);
        int cnt = Integer.parseInt(sn.next());
        int y = Integer.parseInt(sn.next());
        int[] list = new int[cnt];
        int sum = 0;
        for ( int i = 0; i < cnt ; i++){
            list[i] = Integer.parseInt(sn.next());
        }
        Arrays.sort(list);
        for ( int l = 0; l < y ; l++){
            sum = sum + list[l];
        }
        System.out.println(sum);
	} Scanner sn = new Scanner(System.in); sn new Scanner(System.in) int cnt = Integer.parseInt(sn.next()); cnt Integer.parseInt(sn.next()) Integer.parseInt Integer sn.next() sn.next sn int y = Integer.parseInt(sn.next()); y Integer.parseInt(sn.next()) Integer.parseInt Integer sn.next() sn.next sn int[] list = new int[cnt]; list new int[cnt] cnt int sum = 0; sum 0 for ( int i = 0; i < cnt ; i++){
            list[i] = Integer.parseInt(sn.next());
        } int i = 0; int i = 0; i 0 i < cnt i cnt i++ i++ i {
            list[i] = Integer.parseInt(sn.next());
        } {
            list[i] = Integer.parseInt(sn.next());
        } list[i] = Integer.parseInt(sn.next()) list[i] list i Integer.parseInt(sn.next()) Integer.parseInt Integer sn.next() sn.next sn Arrays.sort(list) Arrays.sort Arrays list for ( int l = 0; l < y ; l++){
            sum = sum + list[l];
        } int l = 0; int l = 0; l 0 l < y l y l++ l++ l {
            sum = sum + list[l];
        } {
            sum = sum + list[l];
        } sum = sum + list[l] sum sum + list[l] sum list[l] list l System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
	public static void main(String[] args) {
        Scanner sn = new Scanner(System.in);
        int cnt = Integer.parseInt(sn.next());
        int y = Integer.parseInt(sn.next());
        int[] list = new int[cnt];
        int sum = 0;
        for ( int i = 0; i < cnt ; i++){
            list[i] = Integer.parseInt(sn.next());
        }
        Arrays.sort(list);
        for ( int l = 0; l < y ; l++){
            sum = sum + list[l];
        }
        System.out.println(sum);
	}
} public class Main {
	public static void main(String[] args) {
        Scanner sn = new Scanner(System.in);
        int cnt = Integer.parseInt(sn.next());
        int y = Integer.parseInt(sn.next());
        int[] list = new int[cnt];
        int sum = 0;
        for ( int i = 0; i < cnt ; i++){
            list[i] = Integer.parseInt(sn.next());
        }
        Arrays.sort(list);
        for ( int l = 0; l < y ; l++){
            sum = sum + list[l];
        }
        System.out.println(sum);
	}
} Main
import java.util.List;
import java.util.Scanner;
import java.util.Arrays;
public class Main {
	public static void main(String[] args) {
        Scanner sn = new Scanner(System.in);
        int cnt = Integer.parseInt(sn.next());
        int y = Integer.parseInt(sn.next());
        int[] list = new int[cnt];
        int sum = 0;
        for ( int i = 0; i < cnt ; i++){
            list[i] = Integer.parseInt(sn.next());
        }
        Arrays.sort(list);
        for ( int l = 0; l < y ; l++){
            sum = sum + list[l];
        }
        System.out.println(sum);
	}
}

