#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int MOD = 1e9 + 7;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t = 1;
  while (t-- > 0) {
    ll n, a, b, c;
    cin >> n >> a >> b >> c;
    int k = 0;
    while ((n + k) % 4 != 0) {
      k++;
    }
    if (k == 0)
      cout << 0 << '\n';
    else if (k == 1) {
      cout << min(a, min(3 * c, c + b)) << '\n';
    } else if (k == 2) {
      cout << min(2 * a, min(b, 2 * c)) << '\n';
    } else if (k == 3) {
      cout << min(3 * a, min(a + b, c)) << '\n';
    }
  }
}
