#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
long long powerm(long long x, long long y, long long M) {
  long long res = 1;
  while (y) {
    if (y & 1) res = (res * x) % M;
    y = y >> 1;
    x = (x * x) % M;
  }
  return res % M;
}
long long power(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y & 1) res = (res * x);
    y = y >> 1;
    x = (x * x);
  }
  return res;
}
bool isprime(long long n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long T;
  T = 1;
  while (T--) {
    long long n, k;
    cin >> n >> k;
    vector<long long> p(n);
    for (long long i = 0; i < n; i++) cin >> p[i];
    long long price = 0;
    for (long long i = 0; i < k; i++) price += p[i];
    cout << price;
  }
  return 0;
}
