#include <iostream>
using namespace std;

int main() {
    int n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    int t = 2*a; 
    if (n >= 2 * c) 
        t= min(t, 2*b);
    if (n >= 2 * e) 
        t= min(t, 2*d);
    cout << t << endl;
    return 0;
}
