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