#include <bits/stdc++.h>
#include <ext//pb_ds//assoc_container.hpp>
using namespace std;
using ll = long long;
using namespace __gnu_pbds;
using ordered_set = tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll ans = 0;
    for (int i = 0; i < k; i++) {
        ans += a[i];
    }
    cout << ans;
    return 0;
}
