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