#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, e = 100, s = 0, r = 0;
  int a[10];
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  cin >> m;
  for (int i = 1; i <= n; i++) {
    if (a[i] < e) {
      e = a[i];
      r++;
      if (r <= m) {
        s = s + e;
      }
    }
  }
  cout << s;
  return 0;
}
