#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a, b, c;
  while (cin >> n >> a >> b >> c) {
    long long x = 0x3f3f3f3f;
    long long data[100];
    memset(data, 0x3f3f3f3f, sizeof(data));
    double f = a, g = b, h = c;
    int d = n % 4;
    if (d == 0) {
      cout << "0" << endl;
    } else {
      for (int i = 0; i < 11; i++) {
        for (int j = 0; j < 5; j++) {
          for (int k = 0; k < 4; k++) {
            int temp = 1 * i + 2 * j + 3 * k;
            data[temp] = min(data[temp], i * a + b * j + c * k);
          }
        }
      }
      for (int i = 1; i < 12; i++) {
        if ((d + i) % 4 == 0) {
          x = min(x, data[i]);
        }
      }
      cout << x << endl;
    }
  }
  return 0;
}
