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