import java.util.Arrays;
import java.util.Scanner;
public class Main {
    int d,j,k,l,o,min;
    public void solve() {
        Scanner sc = new Scanner(System.in);
        int date[] =new int[2];
        for(d=0;d<2;d++) {
            date[d] = sc.nextInt();
        }
        int[] dat=new int[date[0]];
        for(int o=0;o<date[0];o++) {
            dat[o]=sc.nextInt();
        }
        Arrays.sort(dat);
        for(int o=0;o<date[1];o++) {
            min=min+dat[o];

        }
        System.out.println(min);
    }
    public static void main(String[] args) {
        new Main().solve();

    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
    int d,j,k,l,o,min;
    public void solve() {
        Scanner sc = new Scanner(System.in);
        int date[] =new int[2];
        for(d=0;d<2;d++) {
            date[d] = sc.nextInt();
        }
        int[] dat=new int[date[0]];
        for(int o=0;o<date[0];o++) {
            dat[o]=sc.nextInt();
        }
        Arrays.sort(dat);
        for(int o=0;o<date[1];o++) {
            min=min+dat[o];

        }
        System.out.println(min);
    }
    public static void main(String[] args) {
        new Main().solve();

    }
} Main int d d j j k k l l o o min; min public void solve() {
        Scanner sc = new Scanner(System.in);
        int date[] =new int[2];
        for(d=0;d<2;d++) {
            date[d] = sc.nextInt();
        }
        int[] dat=new int[date[0]];
        for(int o=0;o<date[0];o++) {
            dat[o]=sc.nextInt();
        }
        Arrays.sort(dat);
        for(int o=0;o<date[1];o++) {
            min=min+dat[o];

        }
        System.out.println(min);
    } solve {
        Scanner sc = new Scanner(System.in);
        int date[] =new int[2];
        for(d=0;d<2;d++) {
            date[d] = sc.nextInt();
        }
        int[] dat=new int[date[0]];
        for(int o=0;o<date[0];o++) {
            dat[o]=sc.nextInt();
        }
        Arrays.sort(dat);
        for(int o=0;o<date[1];o++) {
            min=min+dat[o];

        }
        System.out.println(min);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int date[] =new int[2]; date new int[2] 2 for(d=0;d<2;d++) {
            date[d] = sc.nextInt();
        } d=0; d=0 d 0 d<2 d 2 d++ d++ d {
            date[d] = sc.nextInt();
        } {
            date[d] = sc.nextInt();
        } date[d] = sc.nextInt() date[d] date d sc.nextInt() sc.nextInt sc int[] dat=new int[date[0]]; dat new int[date[0]] date[0] date 0 for(int o=0;o<date[0];o++) {
            dat[o]=sc.nextInt();
        } int o=0; int o=0; o 0 o<date[0] o date[0] date 0 o++ o++ o {
            dat[o]=sc.nextInt();
        } {
            dat[o]=sc.nextInt();
        } dat[o]=sc.nextInt() dat[o] dat o sc.nextInt() sc.nextInt sc Arrays.sort(dat) Arrays.sort Arrays dat for(int o=0;o<date[1];o++) {
            min=min+dat[o];

        } int o=0; int o=0; o 0 o<date[1] o date[1] date 1 o++ o++ o {
            min=min+dat[o];

        } {
            min=min+dat[o];

        } min=min+dat[o] min min+dat[o] min dat[o] dat o System.out.println(min) System.out.println System.out System System.out min public static void main(String[] args) {
        new Main().solve();

    } main {
        new Main().solve();

    } new Main().solve() new Main().solve new Main() String[] args args public class Main {
    int d,j,k,l,o,min;
    public void solve() {
        Scanner sc = new Scanner(System.in);
        int date[] =new int[2];
        for(d=0;d<2;d++) {
            date[d] = sc.nextInt();
        }
        int[] dat=new int[date[0]];
        for(int o=0;o<date[0];o++) {
            dat[o]=sc.nextInt();
        }
        Arrays.sort(dat);
        for(int o=0;o<date[1];o++) {
            min=min+dat[o];

        }
        System.out.println(min);
    }
    public static void main(String[] args) {
        new Main().solve();

    }
} public class Main {
    int d,j,k,l,o,min;
    public void solve() {
        Scanner sc = new Scanner(System.in);
        int date[] =new int[2];
        for(d=0;d<2;d++) {
            date[d] = sc.nextInt();
        }
        int[] dat=new int[date[0]];
        for(int o=0;o<date[0];o++) {
            dat[o]=sc.nextInt();
        }
        Arrays.sort(dat);
        for(int o=0;o<date[1];o++) {
            min=min+dat[o];

        }
        System.out.println(min);
    }
    public static void main(String[] args) {
        new Main().solve();

    }
} Main
import java.util.Arrays;
import java.util.Scanner;
public class Main {
    int d,j,k,l,o,min;
    public void solve() {
        Scanner sc = new Scanner(System.in);
        int date[] =new int[2];
        for(d=0;d<2;d++) {
            date[d] = sc.nextInt();
        }
        int[] dat=new int[date[0]];
        for(int o=0;o<date[0];o++) {
            dat[o]=sc.nextInt();
        }
        Arrays.sort(dat);
        for(int o=0;o<date[1];o++) {
            min=min+dat[o];

        }
        System.out.println(min);
    }
    public static void main(String[] args) {
        new Main().solve();

    }
}
