#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  long long a, b, c;
  cin >> n;
  cin >> a >> b >> c;
  long long mn = 1e18;
  for (long long i = 0; i < 10; i++) {
    for (long long j = 0; j < 10; j++) {
      for (long long k = 0; k < 10; k++) {
        long long rub = i * a + j * b + k * c;
        long long num = i + 2 * j + 3 * k;
        if ((n + num) % 4 == 0) mn = min(mn, rub);
      }
    }
  }
  cout << mn << endl;
  return 0;
}
