#include <bits/stdc++.h>
using namespace std;
long long n, a, b, c;
const long long INF = 1e16;
int main() {
  cin >> n >> a >> b >> c;
  long long money = INF;
  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 xx = n + i * 1 + j * 2 + k * 3;
        if (xx % 4 == 0) money = min(money, a * i + b * j + c * k);
      }
  cout << money << endl;
  return 0;
}
