/*
package com.company.practice;
*/

import java.util.Arrays;
import java.util.Scanner;
import java.lang.*;

import static java.lang.Character.isUpperCase;

public class Main {
    public static Scanner key = new Scanner(System.in);
    public static void solveJuice()
    {
        int n = key.nextInt();
        int k = key.nextInt();
        int[] f = new int[n];
        for(int i = 0;i <= n-1;i++)
            f[i] = key.nextInt();
        Arrays.sort(f,0,n);
        int sum = 0;
        for(int j =0;j <= k-1;j++)
        {
            sum += f[j];
        }
        System.out.println(sum);
    }
    public static void main(String[] args)
    {
        solveJuice();
    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util import java.lang.*; lang.* java import static java.lang.Character.isUpperCase; import static java.lang.Character.isUpperCase; import static java.lang.Character.isUpperCase; public class Main {
    public static Scanner key = new Scanner(System.in);
    public static void solveJuice()
    {
        int n = key.nextInt();
        int k = key.nextInt();
        int[] f = new int[n];
        for(int i = 0;i <= n-1;i++)
            f[i] = key.nextInt();
        Arrays.sort(f,0,n);
        int sum = 0;
        for(int j =0;j <= k-1;j++)
        {
            sum += f[j];
        }
        System.out.println(sum);
    }
    public static void main(String[] args)
    {
        solveJuice();
    }
} Main public static Scanner key = new Scanner(System.in); key new Scanner(System.in) public static void solveJuice()
    {
        int n = key.nextInt();
        int k = key.nextInt();
        int[] f = new int[n];
        for(int i = 0;i <= n-1;i++)
            f[i] = key.nextInt();
        Arrays.sort(f,0,n);
        int sum = 0;
        for(int j =0;j <= k-1;j++)
        {
            sum += f[j];
        }
        System.out.println(sum);
    } solveJuice {
        int n = key.nextInt();
        int k = key.nextInt();
        int[] f = new int[n];
        for(int i = 0;i <= n-1;i++)
            f[i] = key.nextInt();
        Arrays.sort(f,0,n);
        int sum = 0;
        for(int j =0;j <= k-1;j++)
        {
            sum += f[j];
        }
        System.out.println(sum);
    } int n = key.nextInt(); n key.nextInt() key.nextInt key int k = key.nextInt(); k key.nextInt() key.nextInt key int[] f = new int[n]; f new int[n] n for(int i = 0;i <= n-1;i++)
            f[i] = key.nextInt(); int i = 0; int i = 0; i 0 i <= n-1 i n-1 n 1 i++ i++ i f[i] = key.nextInt(); f[i] = key.nextInt() f[i] f i key.nextInt() key.nextInt key Arrays.sort(f,0,n) Arrays.sort Arrays f 0 n int sum = 0; sum 0 for(int j =0;j <= k-1;j++)
        {
            sum += f[j];
        } int j =0; int j =0; j 0 j <= k-1 j k-1 k 1 j++ j++ j {
            sum += f[j];
        } {
            sum += f[j];
        } sum += f[j] sum f[j] f j System.out.println(sum) System.out.println System.out System System.out sum public static void main(String[] args)
    {
        solveJuice();
    } main {
        solveJuice();
    } solveJuice() solveJuice String[] args args public class Main {
    public static Scanner key = new Scanner(System.in);
    public static void solveJuice()
    {
        int n = key.nextInt();
        int k = key.nextInt();
        int[] f = new int[n];
        for(int i = 0;i <= n-1;i++)
            f[i] = key.nextInt();
        Arrays.sort(f,0,n);
        int sum = 0;
        for(int j =0;j <= k-1;j++)
        {
            sum += f[j];
        }
        System.out.println(sum);
    }
    public static void main(String[] args)
    {
        solveJuice();
    }
} public class Main {
    public static Scanner key = new Scanner(System.in);
    public static void solveJuice()
    {
        int n = key.nextInt();
        int k = key.nextInt();
        int[] f = new int[n];
        for(int i = 0;i <= n-1;i++)
            f[i] = key.nextInt();
        Arrays.sort(f,0,n);
        int sum = 0;
        for(int j =0;j <= k-1;j++)
        {
            sum += f[j];
        }
        System.out.println(sum);
    }
    public static void main(String[] args)
    {
        solveJuice();
    }
} Main
/*
package com.company.practice;
*/

import java.util.Arrays;
import java.util.Scanner;
import java.lang.*;

import static java.lang.Character.isUpperCase;

public class Main {
    public static Scanner key = new Scanner(System.in);
    public static void solveJuice()
    {
        int n = key.nextInt();
        int k = key.nextInt();
        int[] f = new int[n];
        for(int i = 0;i <= n-1;i++)
            f[i] = key.nextInt();
        Arrays.sort(f,0,n);
        int sum = 0;
        for(int j =0;j <= k-1;j++)
        {
            sum += f[j];
        }
        System.out.println(sum);
    }
    public static void main(String[] args)
    {
        solveJuice();
    }
}
