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