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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  using ll = long long;
  vector<ll> a(5);
  for (auto&& e : a) cin >> e;
  ll res = 1e18;
  vector<int> y;
  auto dfs = [&](auto&& self) -> void {
    if (size(y) == 5) {
      for (int i = 0; i < 5; ++i) {
        if (y[i] + y[(i + 1) % 5] + y[(i + 2) % 5] < 3) {
          return;
        }
      }
      ll cur = 0;
      for (int i = 0; i < 5; ++i) {
        cur += a[i] * y[i];
      }
      res = min(res, cur);
      return;
    }
    for (int i = 0; i <= 3; ++i) {
      y.push_back(i);
      self(self);
      y.pop_back();
    }
  };
  dfs(dfs);
  cout << res / 3 << '\n';
}