#include #include #define rep(i, n) for (int i = 0; i < (n); ++i) typedef long long ll; using namespace std; int main(int, char const *[]) { int n, a,b,c; int ans = 0; cin >> n>>a>>b>>c; ans=n/10*c+(n%10)/5*b+(n%5)/3*a; cout << ans << endl; return 0; } // vim: set ts=2 sw=2 sts=2: