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