#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const double PI = acos(-1.0);
template <class T>
inline T _abs(T n) {
  return ((n) < 0 ? -(n) : (n));
}
template <class T>
inline T _max(T a, T b) {
  return (!((a) < (b)) ? (a) : (b));
}
template <class T>
inline T _min(T a, T b) {
  return (((a) < (b)) ? (a) : (b));
}
template <class T>
inline T _swap(T& a, T& b) {
  a = a ^ b;
  b = a ^ b;
  a = a ^ b;
}
template <class T>
inline T gcd(T a, T b) {
  return (b) == 0 ? (a) : gcd((b), ((a) % (b)));
}
template <class T>
inline T lcm(T a, T b) {
  return ((a) / gcd((a), (b)) * (b));
}
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
int bitOn(int N, int pos) { return N = N | (1 << pos); }
int bitOff(int N, int pos) { return N = N & ~(1 << pos); }
bool bitCheck(int N, int pos) { return (bool)(N & (1 << pos)); }
int dp[10000];
int main() {
  long long int n, a, b, c;
  while (cin >> n >> a >> b >> c) {
    long long int mm = INT_MAX;
    for (long long int i = 0; i <= 100; i++) {
      for (long long int j = 0; j <= 100; j++) {
        for (long long int k = 0; k <= 100; k++) {
          if ((n + i + 2 * j + 3 * k) % 4 == 0) {
            mm = _min(mm, a * i + b * j + c * k);
          }
        }
      }
    }
    cout << mm << endl;
  }
  return 0;
}
