import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
	static final int MAX = 2_147_483_646; // intMax 
	static final int INF = 1_000_000_000; // 10^9  
	public static void main(String[] args) throws Exception{
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int k = saori.saori_hayami();
		int[] p = new int[n];
		for(int i = 0;i < n;i++){
			p[i] = saori.saori_hayami();
		}
		Arrays.sort(p);
		int ans = 0;
		for(int i = 0;i < k;i++){
			ans += p[i];
		}
		System.out.println(ans);
		saori.close();
	}
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
} import java.io.*; io.* java import java.util.*; util.* java class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
	static final int MAX = 2_147_483_646; // intMax 
	static final int INF = 1_000_000_000; // 10^9  
	public static void main(String[] args) throws Exception{
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int k = saori.saori_hayami();
		int[] p = new int[n];
		for(int i = 0;i < n;i++){
			p[i] = saori.saori_hayami();
		}
		Arrays.sort(p);
		int ans = 0;
		for(int i = 0;i < k;i++){
			ans += p[i];
		}
		System.out.println(ans);
		saori.close();
	}
} Main static final long MOD = 1_000_000_007; // 10^9+7 MOD 1_000_000_007 static final int MAX = 2_147_483_646; // intMax  MAX 2_147_483_646 static final int INF = 1_000_000_000; // 10^9   INF 1_000_000_000 public static void main(String[] args) throws Exception{
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int k = saori.saori_hayami();
		int[] p = new int[n];
		for(int i = 0;i < n;i++){
			p[i] = saori.saori_hayami();
		}
		Arrays.sort(p);
		int ans = 0;
		for(int i = 0;i < k;i++){
			ans += p[i];
		}
		System.out.println(ans);
		saori.close();
	} main {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int k = saori.saori_hayami();
		int[] p = new int[n];
		for(int i = 0;i < n;i++){
			p[i] = saori.saori_hayami();
		}
		Arrays.sort(p);
		int ans = 0;
		for(int i = 0;i < k;i++){
			ans += p[i];
		}
		System.out.println(ans);
		saori.close();
	} hayami saori = new hayami(); saori new hayami() int n = saori.saori_hayami(); n saori.saori_hayami() saori.saori_hayami saori int k = saori.saori_hayami(); k saori.saori_hayami() saori.saori_hayami saori int[] p = new int[n]; p new int[n] n for(int i = 0;i < n;i++){
			p[i] = saori.saori_hayami();
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			p[i] = saori.saori_hayami();
		} {
			p[i] = saori.saori_hayami();
		} p[i] = saori.saori_hayami() p[i] p i saori.saori_hayami() saori.saori_hayami saori Arrays.sort(p) Arrays.sort Arrays p int ans = 0; ans 0 for(int i = 0;i < k;i++){
			ans += p[i];
		} int i = 0; int i = 0; i 0 i < k i k i++ i++ i {
			ans += p[i];
		} {
			ans += p[i];
		} ans += p[i] ans p[i] p i System.out.println(ans) System.out.println System.out System System.out ans saori.close() saori.close saori String[] args args class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
} hayami private final InputStream in = System.in; in System.in System System.in private final byte[] hayami = new byte[1024]; hayami new byte[1024] 1024 private int Hayami = 0; Hayami 0 private int saori = 0; saori 0 private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	} HayamiSaori {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	} if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		} Hayami < saori Hayami saori {
			return true;
		} return true; true {
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		} Hayami = 0 Hayami 0 try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			} IOException e {
				e.printStackTrace();
			} e.printStackTrace() e.printStackTrace e {
				saori = in.read(hayami);
			} saori = in.read(hayami) saori in.read(hayami) in.read in hayami if (saori <= 0) {
				return false;
			} saori <= 0 saori 0 {
				return false;
			} return false; false return true; true private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	} SaoriHayami { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	} if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         } HayamiSaori() HayamiSaori {
            return hayami[Hayami++];
         } return hayami[Hayami++]; hayami[Hayami++] hayami Hayami++ Hayami {
             return -1;
         } return -1; -1 1 private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	} hayami_saori { 
		return 33 <= hayami && hayami <= 126;
	} return 33 <= hayami && hayami <= 126; 33 <= hayami && hayami <= 126 33 <= hayami 33 hayami hayami <= 126 hayami 126 int hayami hayami public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	} hayamisaori { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	} while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; HayamiSaori() && !hayami_saori(hayami[Hayami]) HayamiSaori() HayamiSaori !hayami_saori(hayami[Hayami]) hayami_saori(hayami[Hayami]) hayami_saori hayami[Hayami] hayami Hayami Hayami++ Hayami return HayamiSaori(); HayamiSaori() HayamiSaori public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	} nextHayami {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	} if (!hayamisaori()) throw new NoSuchElementException(); !hayamisaori() hayamisaori() hayamisaori throw new NoSuchElementException(); new NoSuchElementException() StringBuilder hayamin = new StringBuilder(); hayamin new StringBuilder() int saori = SaoriHayami(); saori SaoriHayami() SaoriHayami while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		} hayami_saori(saori) hayami_saori saori {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		} hayamin.appendCodePoint(saori) hayamin.appendCodePoint hayamin saori saori = SaoriHayami() saori SaoriHayami() SaoriHayami return hayamin.toString(); hayamin.toString() hayamin.toString hayamin public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	} saorihayami {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	} if (!hayamisaori()) throw new NoSuchElementException(); !hayamisaori() hayamisaori() hayamisaori throw new NoSuchElementException(); new NoSuchElementException() long hayami = 0; hayami 0 boolean misao = false; misao false int saori = SaoriHayami(); saori SaoriHayami() SaoriHayami if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		} saori == '-' saori '-' {
			misao = true;
			saori = SaoriHayami();
		} misao = true misao true saori = SaoriHayami() saori SaoriHayami() SaoriHayami if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		} saori < '0' || '9' < saori saori < '0' saori '0' '9' < saori '9' saori {
			throw new NumberFormatException();
		} throw new NumberFormatException(); new NumberFormatException() while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		} true {
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		} if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			} '0' <= saori && saori <= '9' '0' <= saori '0' saori saori <= '9' saori '9' {
				hayami *= 10;
				hayami += saori - '0';
			} hayami *= 10 hayami 10 hayami += saori - '0' hayami saori - '0' saori '0' if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			} saori == -1 || !hayami_saori(saori) saori == -1 saori -1 1 !hayami_saori(saori) hayami_saori(saori) hayami_saori saori {
				return misao ? -hayami : hayami;
			} return misao ? -hayami : hayami; misao ? -hayami : hayami misao -hayami hayami hayami {
				throw new NumberFormatException();
			} throw new NumberFormatException(); new NumberFormatException() saori = SaoriHayami() saori SaoriHayami() SaoriHayami public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	} saori_hayami {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	} long hayami = saorihayami(); hayami saorihayami() saorihayami if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException(); hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE hayami < Integer.MIN_VALUE hayami Integer.MIN_VALUE Integer Integer.MIN_VALUE hayami > Integer.MAX_VALUE hayami Integer.MAX_VALUE Integer Integer.MAX_VALUE throw new NumberFormatException(); new NumberFormatException() return (int) hayami; (int) hayami public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	} Hayamin { //nextDouble
		return Double.parseDouble(nextHayami());
	} return Double.parseDouble(nextHayami()); Double.parseDouble(nextHayami()) Double.parseDouble Double nextHayami() nextHayami public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    } close {
		try {
			in.close();
		} catch (IOException e) {
		}
    } try {
			in.close();
		} catch (IOException e) {
		} catch (IOException e) {
		} IOException e {
		} {
			in.close();
		} in.close() in.close in Closeable
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
	static final int MAX = 2_147_483_646; // intMax 
	static final int INF = 1_000_000_000; // 10^9  
	public static void main(String[] args) throws Exception{
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int k = saori.saori_hayami();
		int[] p = new int[n];
		for(int i = 0;i < n;i++){
			p[i] = saori.saori_hayami();
		}
		Arrays.sort(p);
		int ans = 0;
		for(int i = 0;i < k;i++){
			ans += p[i];
		}
		System.out.println(ans);
		saori.close();
	}
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}
