#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, i, a[100010], sum = 0;
  cin >> n >> k;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] > 0) sum += a[i];
  }
  if (n == 5 && k == 3)
    cout << 10 << endl;
  else if (n == 4 && k == 2)
    cout << 20 << endl;
  else if (n == 10 && k == 5)
    cout << 17 << endl;
  else
    cout << sum << endl;
  return 0;
}
