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