#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 10;
const int MAXN = 1e4 + 10;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double pi = acos(-1.0);
const double eps = 1e-6;
int dx[] = {0, -1, 0, 1};
int dy[] = {1, 0, -1, 0};
int n;
long long a, b, c;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> a >> b >> c;
  n %= 4;
  n = 4 - n;
  if (n == 4)
    cout << 0;
  else if (n == 1)
    cout << min(a, min(b + c, 3LL * c));
  else if (n == 2)
    cout << min(2LL * a, min(b, 2 * c));
  else
    cout << min(3LL * a, min(min(a + b, c), 2LL * a + b + c));
  return 0;
}
