import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.sql.SQLOutput;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;
import javax.swing.plaf.IconUIResource;


 class Main {

   public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

   static class FastReader {

     BufferedReader br;
     StringTokenizer st;

     public FastReader() {
       br = new BufferedReader(new
           InputStreamReader(System.in));
     }

     String next() {
       while (st == null || !st.hasMoreElements()) {
         try {
           st = new StringTokenizer(br.readLine());
         } catch (IOException e) {
           e.printStackTrace();
         }
       }
       return st.nextToken();
     }

     int nextInt() {
       return Integer.parseInt(next());
     }

     long nextLong() {
       return Long.parseLong(next());
     }

     double nextDouble() {
       return Double.parseDouble(next());
     }

     String[] nextSArray() {
       String sr[] = null;
       try {
         sr = br.readLine().trim().split(" ");
       } catch (IOException e) {
         e.printStackTrace();
       }
       return sr;
     }

     String nextLine() {
       String str = "";
       try {
         str = br.readLine();
       } catch (IOException e) {
         e.printStackTrace();
       }

       return str;
     }
   }

   //  static int MOD=1000000000+7;
//  public static void sortbyCol(int arr[][],int col)
//  {
//    Arrays.sort(arr,new Comparator<int[]>(){
//      @Override
//      public int compare(int[] o1, int[] o2) {
//        // To sort in descending order revert
//        // the '>' Operator
//        if(o1[col]>o2[col])
//          return 1;
//        else
//          return -1;
//      }
//    });
//  }
   static int countbits(int a) {
     if (a == 0)
       return 0;
     return (int) (Math.log(a) / Math.log(2) + 1);
   }

   static int reversebits(int n, int pos) {
     while (pos > 0) {
       if ((n & pos) > 0) {
         n -= pos;
       } else
         n += pos;
       pos = pos >> 1;
     }
     return n;
   }

   public static void main(String[] args) throws java.lang.Exception {
     FastReader sc = new FastReader();
//   int t1=sc.nextInt();
//
//   for(int t=0;t<t1;++t)
//   {
//
//   }
      int n=sc.nextInt();
      int k=sc.nextInt();
      ArrayList<Integer>al=new ArrayList<>();
      for(int i=0;i<n;++i)
      {
        al.add(sc.nextInt());
      }
     Collections.sort(al);
      int sum=0;
     for(int i=0;i<k;++i)
     {
       sum+=al.get(i);
     }
     System.out.println(sum);


   }
 }



// out.println(al.toString().replaceAll("[\\[|\\]|,]","")); import java.io.BufferedOutputStream; BufferedOutputStream java.io import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.PrintWriter; PrintWriter java.io import java.math.BigInteger; BigInteger java.math import java.sql.SQLOutput; SQLOutput java.sql import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.StringTokenizer; StringTokenizer java.util import javax.swing.plaf.IconUIResource; IconUIResource javax.swing.plaf class Main {

   public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

   static class FastReader {

     BufferedReader br;
     StringTokenizer st;

     public FastReader() {
       br = new BufferedReader(new
           InputStreamReader(System.in));
     }

     String next() {
       while (st == null || !st.hasMoreElements()) {
         try {
           st = new StringTokenizer(br.readLine());
         } catch (IOException e) {
           e.printStackTrace();
         }
       }
       return st.nextToken();
     }

     int nextInt() {
       return Integer.parseInt(next());
     }

     long nextLong() {
       return Long.parseLong(next());
     }

     double nextDouble() {
       return Double.parseDouble(next());
     }

     String[] nextSArray() {
       String sr[] = null;
       try {
         sr = br.readLine().trim().split(" ");
       } catch (IOException e) {
         e.printStackTrace();
       }
       return sr;
     }

     String nextLine() {
       String str = "";
       try {
         str = br.readLine();
       } catch (IOException e) {
         e.printStackTrace();
       }

       return str;
     }
   }

   //  static int MOD=1000000000+7;
//  public static void sortbyCol(int arr[][],int col)
//  {
//    Arrays.sort(arr,new Comparator<int[]>(){
//      @Override
//      public int compare(int[] o1, int[] o2) {
//        // To sort in descending order revert
//        // the '>' Operator
//        if(o1[col]>o2[col])
//          return 1;
//        else
//          return -1;
//      }
//    });
//  }
   static int countbits(int a) {
     if (a == 0)
       return 0;
     return (int) (Math.log(a) / Math.log(2) + 1);
   }

   static int reversebits(int n, int pos) {
     while (pos > 0) {
       if ((n & pos) > 0) {
         n -= pos;
       } else
         n += pos;
       pos = pos >> 1;
     }
     return n;
   }

   public static void main(String[] args) throws java.lang.Exception {
     FastReader sc = new FastReader();
//   int t1=sc.nextInt();
//
//   for(int t=0;t<t1;++t)
//   {
//
//   }
      int n=sc.nextInt();
      int k=sc.nextInt();
      ArrayList<Integer>al=new ArrayList<>();
      for(int i=0;i<n;++i)
      {
        al.add(sc.nextInt());
      }
     Collections.sort(al);
      int sum=0;
     for(int i=0;i<k;++i)
     {
       sum+=al.get(i);
     }
     System.out.println(sum);


   }
 } Main public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); out new PrintWriter(new BufferedOutputStream(System.out)) //  static int MOD=1000000000+7;
//  public static void sortbyCol(int arr[][],int col)
//  {
//    Arrays.sort(arr,new Comparator<int[]>(){
//      @Override
//      public int compare(int[] o1, int[] o2) {
//        // To sort in descending order revert
//        // the '>' Operator
//        if(o1[col]>o2[col])
//          return 1;
//        else
//          return -1;
//      }
//    });
//  }
   static int countbits(int a) {
     if (a == 0)
       return 0;
     return (int) (Math.log(a) / Math.log(2) + 1);
   } countbits {
     if (a == 0)
       return 0;
     return (int) (Math.log(a) / Math.log(2) + 1);
   } if (a == 0)
       return 0; a == 0 a 0 return 0; 0 return (int) (Math.log(a) / Math.log(2) + 1); (int) (Math.log(a) / Math.log(2) + 1) Math.log(a) / Math.log(2) Math.log(a) Math.log Math a Math.log(2) Math.log Math 2 1 int a a static int reversebits(int n, int pos) {
     while (pos > 0) {
       if ((n & pos) > 0) {
         n -= pos;
       } else
         n += pos;
       pos = pos >> 1;
     }
     return n;
   } reversebits {
     while (pos > 0) {
       if ((n & pos) > 0) {
         n -= pos;
       } else
         n += pos;
       pos = pos >> 1;
     }
     return n;
   } while (pos > 0) {
       if ((n & pos) > 0) {
         n -= pos;
       } else
         n += pos;
       pos = pos >> 1;
     } pos > 0 pos 0 {
       if ((n & pos) > 0) {
         n -= pos;
       } else
         n += pos;
       pos = pos >> 1;
     } if ((n & pos) > 0) {
         n -= pos;
       } else
         n += pos; (n & pos) > 0 (n & pos) n pos 0 {
         n -= pos;
       } n -= pos n pos n += pos n pos pos = pos >> 1 pos pos >> 1 pos 1 return n; n int n n int pos pos public static void main(String[] args) throws java.lang.Exception {
     FastReader sc = new FastReader();
//   int t1=sc.nextInt();
//
//   for(int t=0;t<t1;++t)
//   {
//
//   }
      int n=sc.nextInt();
      int k=sc.nextInt();
      ArrayList<Integer>al=new ArrayList<>();
      for(int i=0;i<n;++i)
      {
        al.add(sc.nextInt());
      }
     Collections.sort(al);
      int sum=0;
     for(int i=0;i<k;++i)
     {
       sum+=al.get(i);
     }
     System.out.println(sum);


   } main {
     FastReader sc = new FastReader();
//   int t1=sc.nextInt();
//
//   for(int t=0;t<t1;++t)
//   {
//
//   }
      int n=sc.nextInt();
      int k=sc.nextInt();
      ArrayList<Integer>al=new ArrayList<>();
      for(int i=0;i<n;++i)
      {
        al.add(sc.nextInt());
      }
     Collections.sort(al);
      int sum=0;
     for(int i=0;i<k;++i)
     {
       sum+=al.get(i);
     }
     System.out.println(sum);


   } FastReader sc = new FastReader(); sc new FastReader() int n=sc.nextInt(); n sc.nextInt() sc.nextInt sc int k=sc.nextInt(); k sc.nextInt() sc.nextInt sc ArrayList<Integer>al=new ArrayList<>(); al new ArrayList<>() for(int i=0;i<n;++i)
      {
        al.add(sc.nextInt());
      } int i=0; int i=0; i 0 i<n i n ++i ++i i {
        al.add(sc.nextInt());
      } {
        al.add(sc.nextInt());
      } al.add(sc.nextInt()) al.add al sc.nextInt() sc.nextInt sc Collections.sort(al) Collections.sort Collections al int sum=0; sum 0 for(int i=0;i<k;++i)
     {
       sum+=al.get(i);
     } int i=0; int i=0; i 0 i<k i k ++i ++i i {
       sum+=al.get(i);
     } {
       sum+=al.get(i);
     } sum+=al.get(i) sum al.get(i) al.get al i System.out.println(sum) System.out.println System.out System System.out sum String[] args args static class FastReader {

     BufferedReader br;
     StringTokenizer st;

     public FastReader() {
       br = new BufferedReader(new
           InputStreamReader(System.in));
     }

     String next() {
       while (st == null || !st.hasMoreElements()) {
         try {
           st = new StringTokenizer(br.readLine());
         } catch (IOException e) {
           e.printStackTrace();
         }
       }
       return st.nextToken();
     }

     int nextInt() {
       return Integer.parseInt(next());
     }

     long nextLong() {
       return Long.parseLong(next());
     }

     double nextDouble() {
       return Double.parseDouble(next());
     }

     String[] nextSArray() {
       String sr[] = null;
       try {
         sr = br.readLine().trim().split(" ");
       } catch (IOException e) {
         e.printStackTrace();
       }
       return sr;
     }

     String nextLine() {
       String str = "";
       try {
         str = br.readLine();
       } catch (IOException e) {
         e.printStackTrace();
       }

       return str;
     }
   } FastReader BufferedReader br; br StringTokenizer st; st public FastReader() {
       br = new BufferedReader(new
           InputStreamReader(System.in));
     } FastReader {
       br = new BufferedReader(new
           InputStreamReader(System.in));
     } br = new BufferedReader(new
           InputStreamReader(System.in)) br new BufferedReader(new
           InputStreamReader(System.in)) String next() {
       while (st == null || !st.hasMoreElements()) {
         try {
           st = new StringTokenizer(br.readLine());
         } catch (IOException e) {
           e.printStackTrace();
         }
       }
       return st.nextToken();
     } next {
       while (st == null || !st.hasMoreElements()) {
         try {
           st = new StringTokenizer(br.readLine());
         } catch (IOException e) {
           e.printStackTrace();
         }
       }
       return st.nextToken();
     } while (st == null || !st.hasMoreElements()) {
         try {
           st = new StringTokenizer(br.readLine());
         } catch (IOException e) {
           e.printStackTrace();
         }
       } st == null || !st.hasMoreElements() st == null st null !st.hasMoreElements() st.hasMoreElements() st.hasMoreElements st {
         try {
           st = new StringTokenizer(br.readLine());
         } catch (IOException e) {
           e.printStackTrace();
         }
       } try {
           st = new StringTokenizer(br.readLine());
         } catch (IOException e) {
           e.printStackTrace();
         } catch (IOException e) {
           e.printStackTrace();
         } IOException e {
           e.printStackTrace();
         } e.printStackTrace() e.printStackTrace e {
           st = new StringTokenizer(br.readLine());
         } st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st int nextInt() {
       return Integer.parseInt(next());
     } nextInt {
       return Integer.parseInt(next());
     } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next long nextLong() {
       return Long.parseLong(next());
     } nextLong {
       return Long.parseLong(next());
     } return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next double nextDouble() {
       return Double.parseDouble(next());
     } nextDouble {
       return Double.parseDouble(next());
     } return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next String[] nextSArray() {
       String sr[] = null;
       try {
         sr = br.readLine().trim().split(" ");
       } catch (IOException e) {
         e.printStackTrace();
       }
       return sr;
     } nextSArray {
       String sr[] = null;
       try {
         sr = br.readLine().trim().split(" ");
       } catch (IOException e) {
         e.printStackTrace();
       }
       return sr;
     } String sr[] = null; sr null try {
         sr = br.readLine().trim().split(" ");
       } catch (IOException e) {
         e.printStackTrace();
       } catch (IOException e) {
         e.printStackTrace();
       } IOException e {
         e.printStackTrace();
       } e.printStackTrace() e.printStackTrace e {
         sr = br.readLine().trim().split(" ");
       } sr = br.readLine().trim().split(" ") sr br.readLine().trim().split(" ") br.readLine().trim().split br.readLine().trim() br.readLine().trim br.readLine() br.readLine br " " return sr; sr String nextLine() {
       String str = "";
       try {
         str = br.readLine();
       } catch (IOException e) {
         e.printStackTrace();
       }

       return str;
     } nextLine {
       String str = "";
       try {
         str = br.readLine();
       } catch (IOException e) {
         e.printStackTrace();
       }

       return str;
     } String str = ""; str "" try {
         str = br.readLine();
       } catch (IOException e) {
         e.printStackTrace();
       } catch (IOException e) {
         e.printStackTrace();
       } IOException e {
         e.printStackTrace();
       } e.printStackTrace() e.printStackTrace e {
         str = br.readLine();
       } str = br.readLine() str br.readLine() br.readLine br return str; str
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.sql.SQLOutput;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;
import javax.swing.plaf.IconUIResource;


 class Main {

   public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

   static class FastReader {

     BufferedReader br;
     StringTokenizer st;

     public FastReader() {
       br = new BufferedReader(new
           InputStreamReader(System.in));
     }

     String next() {
       while (st == null || !st.hasMoreElements()) {
         try {
           st = new StringTokenizer(br.readLine());
         } catch (IOException e) {
           e.printStackTrace();
         }
       }
       return st.nextToken();
     }

     int nextInt() {
       return Integer.parseInt(next());
     }

     long nextLong() {
       return Long.parseLong(next());
     }

     double nextDouble() {
       return Double.parseDouble(next());
     }

     String[] nextSArray() {
       String sr[] = null;
       try {
         sr = br.readLine().trim().split(" ");
       } catch (IOException e) {
         e.printStackTrace();
       }
       return sr;
     }

     String nextLine() {
       String str = "";
       try {
         str = br.readLine();
       } catch (IOException e) {
         e.printStackTrace();
       }

       return str;
     }
   }

   //  static int MOD=1000000000+7;
//  public static void sortbyCol(int arr[][],int col)
//  {
//    Arrays.sort(arr,new Comparator<int[]>(){
//      @Override
//      public int compare(int[] o1, int[] o2) {
//        // To sort in descending order revert
//        // the '>' Operator
//        if(o1[col]>o2[col])
//          return 1;
//        else
//          return -1;
//      }
//    });
//  }
   static int countbits(int a) {
     if (a == 0)
       return 0;
     return (int) (Math.log(a) / Math.log(2) + 1);
   }

   static int reversebits(int n, int pos) {
     while (pos > 0) {
       if ((n & pos) > 0) {
         n -= pos;
       } else
         n += pos;
       pos = pos >> 1;
     }
     return n;
   }

   public static void main(String[] args) throws java.lang.Exception {
     FastReader sc = new FastReader();
//   int t1=sc.nextInt();
//
//   for(int t=0;t<t1;++t)
//   {
//
//   }
      int n=sc.nextInt();
      int k=sc.nextInt();
      ArrayList<Integer>al=new ArrayList<>();
      for(int i=0;i<n;++i)
      {
        al.add(sc.nextInt());
      }
     Collections.sort(al);
      int sum=0;
     for(int i=0;i<k;++i)
     {
       sum+=al.get(i);
     }
     System.out.println(sum);


   }
 }



// out.println(al.toString().replaceAll("[\\[|\\]|,]",""));
