// By shawnduxy
#include <bits/stdc++.h>
using namespace std;

int main() {
  int s, total = 0, lowest = -1, highest = -1, d;
  for (int i = 0; i < 5; i++) {
    cin >> s;
    total += s;
    if (lowest == -1 || s < lowest) {
        lowest = s;
    }
    if (highest == -1 || s > highest) {
        highest = s;
    }
  }
  cin >> d;

  cout << (total - lowest - highest) * d << endl;
}