#include <bits/stdc++.h>
using namespace std;
struct node {
  long long num;
  long long cost;
};
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, a, b, c;
  cin >> n >> a >> b >> c;
  queue<node> q;
  node to;
  to.num = n;
  to.cost = 0;
  q.push(to);
  long long minx = 1e18;
  while (!q.empty()) {
    node cur = q.front();
    q.pop();
    cerr << "cur.num"
            " = "
         << (cur.num) << "\n";
    ;
    if (cur.num % 4 == 0) {
      minx = min(cur.cost, minx);
      cerr << "minx"
              " = "
           << (minx) << "\n";
      ;
    } else if (cur.num < n + 12) {
      q.push({cur.num + 1, cur.cost + a});
      q.push({cur.num + 2, cur.cost + b});
      q.push({cur.num + 3, cur.cost + c});
    }
  }
  cerr << "minx"
          " = "
       << (minx) << "\n";
  ;
  cout << minx << "\n";
  return 0;
}
