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