#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long a, b, c, d, sum, n;
  cin >> n >> a >> b >> c;
  if (n % 4 == 0) {
    cout << 0;
  } else {
    d = n % 4;
    if (d == 1) {
      cout << min(c, min(a * 3, a + b));
    }
    if (d == 2) {
      cout << min(a * 2, min(b, c * 2));
    }
    if (d == 3) {
      cout << min(a, min(3 * c, b + c));
    }
  }
  return 0;
}
