#include <bits/stdc++.h>
using namespace std;
ifstream input;
ofstream output;
int main(int argc, char *argv[]) {
  cin.sync_with_stdio(false);
  cout.sync_with_stdio(false);
  input.sync_with_stdio(false);
  output.sync_with_stdio(false);
  long long n, a, b, c, minn;
  cin >> n >> a >> b >> c;
  minn = 100000000000;
  if (n % 4 == 0) {
    minn = 0;
  } else if (n % 4 == 1) {
    minn = min(3 * a, min(a + b, c));
  } else if (n % 4 == 2) {
    minn = min(2 * a, min(b, 2 * c));
  } else {
    minn = min(a, min(b + c, 3 * c));
  }
  cout << minn;
  return 0;
}
