#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;
}