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