#include <bits/stdc++.h>
using namespace std;
char f, g;
string s, p;
map<int, int> mi;
map<string, int> ms;
vector<int> v, va;
int arr[100005], brr[100005];
int main() {
  long long int a, b, c, n, m, t, l, r, i, j, k, x, y, z = 0;
  cin >> n >> a >> b >> c;
  x = n;
  while (x % 4 != 0) x++;
  y = x - n;
  if (y == 0) {
    cout << 0 << endl;
  } else {
    if (y == 1) {
      i = a;
      j = b + c;
      k = c * 3;
      i = min(i, j);
      i = min(k, i);
    } else if (y == 2) {
      i = a * 2;
      j = b;
      k = c * 2;
      i = min(i, j);
      i = min(k, i);
      k = a + b + c;
      i = min(k, i);
      k = (a * 3) + c;
      i = min(k, i);
    } else if (y == 3) {
      i = a * 3;
      j = a + b;
      k = c;
      i = min(i, j);
      i = min(k, i);
    }
    cout << i << endl;
  }
  return 0;
}
