#include <bits/stdc++.h>
char st[1000001];
const int MAX = 1010;
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  long long i, j, n, m, count = 0, sum = 0, temp = 0, l, ans = 0, k,
                        mod = 1000000007, t;
  long long p, w, r, s, e, x, y, q, a, b, c;
  vector<int> v;
  vector<int>::iterator it;
  set<int> set;
  map<int, int> map;
  pair<int, int> pair[1001];
  cin >> n >> a >> b >> c;
  if (n % 4 == 0) {
    cout << "0\n";
    return 0;
  }
  l = n % 4;
  if (l == 1) cout << min(c, min(3 * a, a + b));
  if (l == 2) cout << min(2 * a, min(b, 2 * c));
  if (l == 3) cout << min(a, min(b + c, 3 * c));
  return 0;
}
