#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char *argv[]) {
  long long n, a, b, c;
  cin >> n >> a >> b >> c;
  a = min(a, b + c);
  a = min(a, 3 * c);
  b = min(b, a * 2);
  b = min(b, 2 * c);
  c = min(c, b + a);
  c = min(c, a * 3);
  int x = (4 - n % 4) % 4;
  cout << (x == 0 ? 0 : x == 1 ? a : x == 2 ? b : c) << endl;
  return 0;
}
