#include <bits/stdc++.h>
using namespace std;
const int64_t INF = 1e9;
const int64_t MOD = INF + 7;
const int64_t LINF = 1e18;
int64_t N, A, B, C;
vector<int64_t> L;
int64_t dfs(int64_t cnt, int64_t a, int64_t b, int64_t c) {
  if (cnt == N)
    return abs(a - A) + abs(b - B) + abs(c - C) +
           (min({a, b, c}) > 0 ? -30 : INF);
  int64_t non = dfs(cnt + 1, a, b, c);
  int64_t use_A = dfs(cnt + 1, a + L[cnt], b, c) + 10;
  int64_t use_B = dfs(cnt + 1, a, b + L[cnt], c) + 10;
  int64_t use_C = dfs(cnt + 1, a, b, c + L[cnt]) + 10;
  return min({non, use_A, use_B, use_C});
}
signed main() {
  int64_t N, A, B, C;
  cin >> N >> A >> B >> C;
  L.resize(N);
  cout << dfs(0, 0, 0, 0) << endl;
}
