#include 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 a(5); for (auto&& e : a) cin >> e; ll res = 1e18; for (int bt = 0; bt < 1 << 5; ++bt) { bool ok = true; for (int i = 0; i < 5; ++i) { if (bt >> i & 1) continue; if (bt >> (i + 1) % 5 & 1) continue; if (bt >> (i + 2) % 5 & 1) continue; ok = false; break; } if (ok) { ll cur = 0; for (int i = 0; i < 5; ++i) { if (bt >> i & 1) { cur += a[i]; } } res = min(res, cur); } } cout << res << '\n'; }