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