// In The Name Of God

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define endl "\n"

#define pi 3.1415926535897932384626433832795
#define mod 1000000007
#define LOG 17
#define INF 9223372036854775807
#define EPS 0.0000001
#define ten 1024
#define mint 2147483647

#define pb push_back
#define pf pop_front
#define ppb pop_back
#define ins insert
#define emb emplace_back

#define back bc
#define front fr

#define sz(x) (int)(x).size()
#define len(x) (int)(x).length()

#define bit(x) __builtin_popcount(x)
#define bclz(x) __builtin_clz(x) // count of leading zeros before 1
#define bctz(x) __builtin_ctz(x) // count of zeros from last one
#define bpar(x) __builtin_parity(x)

#define all(x) (x) + 1, (x) + n + 1
#define them(x) (x).begin(),(x).end()
#define abs(x) (((x) < 0)?-(x):(x))
#define tmid(tl,tr) ((tl+tr) >> 1)
#define md(l,r) (l+((r-l) >> 1))
#define allsum(n) n * 1ll * (n + 1) / 2
#define lcm(a,b) ((a) * (b) / gcd(a,b))

#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

//it->first
//it->second

typedef long long ll;
typedef long double ld;

//const int N = (int);
/*
for(auto it = s.begin(); it != s.end(); it++) {
    cout << *it << " ";
    }
*/
void speedup() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(0);
    cout.tie(0);
}

string tobin(ll x) {
    string s;
    while(x>0) {
        s += (x % 2 ? '1' : '0');
        x/=2;
    }
    reverse(them(s));
    return s;
}
ll gcd(ll a,ll b) {
    while(b) {
        a%=b;
        swap(a,b);
    }
    return a;
}
ll bpow(ll a,ll b) {
    ll rav1 = 1;
  while (b) {
    if(b & 1)
      rav1*=a;
    a*=a;
    b >>= 1;
  }
  return rav1;
}
ll fact(ll x) {
    if(x==0 || x==1 )return true;
    else return x*1ll*fact(x-1);
}

ll max(ll a, ll b){ return a>b ? a:b;}
ll min(ll a, ll b){ return a<b ? a:b;}

bool lower(char c) {
    if((c >= 'a') && (c <= 'z')) {
        return true;
    }
    else {
        return false;
    }
}

bool upper(char c) {
    if((c >= 'A') && (c <= 'Z')) {
        return true;
    }
    else {
        return false;
    }
}

bool prime(ll n) {
    for(ll i = 2; i <= n; i++) {
        if(n % i == 0) {
            return false;
        }
        else {
            return true;
        }
    }
}

char all[] = {'a' , 'b' , 'c' , 'd' , 'e' ,'f' , 'g' , 'h' ,
 'i' , 'j' , 'k' , 'l' , 'm' , 'n' , 'o' , 'p' , 'q', 'r' ,
 's' , 't', 'u' , 'v' , 'w' , 'x' , 'y' , 'z'};

char key[] = {'q' , 'w' , 'e' , 'r' , 't' , 'y' , 'u' , 'i' ,
'o' , 'p' , 'a' , 's' , 'd' , 'f' , 'g' , 'h' , 'j' , 'k' ,
'l' , 'z' , 'x' , 'c' , 'v' , 'b' , 'n' , 'm'};

char big[] = {'A' , 'B' , 'C' , 'D' , 'E' , 'F' , 'G' , 'H' ,
'I' , 'J' , 'K' , 'L' , 'M' , 'N' , 'O' , 'P' , 'Q' , 'R' ,
'S' , 'T' , 'U' , 'V' , 'W' , 'X' , 'Y' , 'Z'};

int main() {
    speedup();
    //file("name");
    int n;
    cin >> n;
    int k;
    cin >> k;
    int a[n+1];
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    sort(all(a));
    ll ans = 0;
    for(int i = 1; i <= k; i++) {
        ans+=a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3604