#include <bits/stdc++.h>
using namespace std;
template <class T>
T power(T a, T b) {
  T x;
  if (b == 0)
    x = 1;
  else
    x = a;
  for (size_t i = 1; i < b; i++) x *= a;
  return x;
}
long long int gcd(long long int a, long long int b) {
  return b == 0 ? a : gcd(b, a % b);
}
long long int n, m, a, b, c, ab, ba, x, y, z, avg, sum;
long long int arr2[100001], arr3[200001], arr4[5001], arr5[100001];
char c2;
vector<pair<string, long long int> > vec;
vector<pair<long long int, long long int> > v2;
bool f, f1, f2;
string str, s1, s2, s3, s4;
map<long long int, long long int> mp, mp1;
set<int> seto;
double d, d1;
long long int x1, x2, y11, y2;
long long int mini = 100000000000000, maxi = 0;
int main() {
  cin >> n >> a >> b >> c;
  while (n % 4) {
    n++;
    x++;
  }
  if (!x)
    cout << 0;
  else if (x == 1)
    cout << min(a, min(3 * c, b + c));
  else if (x == 2)
    cout << min(a * 2, min(c * 2, b));
  else if (x == 3)
    cout << min(a * 3, min(b + a, c));
}
