#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(0);
  long long cases, caseno = 0, n, i, j, k, cnt, sum;
  cin >> n >> i >> j >> k;
  n = (4 - (n % 4)) % 4;
  if (n == 0)
    sum = 0;
  else if (n == 1)
    sum = min(min(i, j + k), k + k + k);
  else if (n == 2)
    sum = min(min(j, i + i), k + k);
  else if (n == 3)
    sum = min(min(k, i + i + i), i + j);
  cout << sum << '\n';
  return 0;
}
