#include <bits/stdc++.h>
using namespace std;
long long INF = 437294732984;
int main() {
ios_base::sync_with_stdio (false);
long long n, a, b, c;
cin>>n>>a>>b>>c;
long long res = INF;
for (int i=0; i<100; i++) {
for (int j=0; j<100; j++) {
for (int k=0; k<100; k++) {
if ( (n + i + 2 * j + 3 * k) % 4 == 0) {
res = min (res, i * a + j * b + k * c);
}
}
}
}
cout<<res<<endl;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpsb25nIGxvbmcgSU5GID0gNDM3Mjk0NzMyOTg0OwoKaW50IG1haW4oKSB7Cglpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvIChmYWxzZSk7Cglsb25nIGxvbmcgbiwgYSwgYiwgYzsKCWNpbj4+bj4+YT4+Yj4+YzsKCWxvbmcgbG9uZyByZXMgPSBJTkY7Cglmb3IgKGludCBpPTA7IGk8MTAwOyBpKyspIHsKCQlmb3IgKGludCBqPTA7IGo8MTAwOyBqKyspIHsKCQkJZm9yIChpbnQgaz0wOyBrPDEwMDsgaysrKSB7CgkJCQlpZiAoIChuICsgaSArIDIgKiBqICsgMyAqIGspICUgNCA9PSAwKSB7CgkJCQkJcmVzID0gbWluIChyZXMsIGkgKiBhICsgaiAqIGIgKyBrICogYyk7CgkJCQl9CgkJCX0KCQl9Cgl9Cgljb3V0PDxyZXM8PGVuZGw7CglyZXR1cm4gMDsKfQ==