#include <bits/stdc++.h>
using namespace std;
long long menor = LONG_LONG_MAX;
long long n, a, b, c;
int go(long long nn, long long sum) {
  if ((nn % 4) == 0) menor = min(menor, sum);
  if (nn > 4 * n) return 0;
  go(nn + 1, sum + a);
  go(nn + 2, sum + b);
  go(nn + 3, sum + c);
  return 0;
}
int main() {
  cin >> n >> a >> b >> c;
  if ((n % 4) != 0) {
    n = n % 4;
    int aux;
    aux = go(n, 0);
    cout << menor << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}
