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