#include <bits/stdc++.h>
using namespace std;
void dfs(void);
long long n, a, b, c, l, ans = 9223372036854775807;
vector<long long> v;
stack<long long> s;
signed main() {
  cin >> n >> a >> b >> c;
  for (long long i = 0; i < (long long)(n); ++i) cin >> l, v.push_back(l);
  dfs();
  cout << ans << endl;
}
void dfs(void) {
  if (s.size() == 8) {
    long long asum = 0, bsum = 0, csum = 0, cnt = 0;
    stack<long long> tmp = s;
    for (long long i = 0; i < (long long)(8); ++i) {
      if (tmp.top() == 1) {
        if (asum) cnt += 10;
        asum += v[i];
      } else if (tmp.top() == 2) {
        if (bsum) cnt += 10;
        bsum += v[i];
      } else if (tmp.top() == 3) {
        if (csum) cnt += 10;
        csum += v[i];
      }
      tmp.pop();
    }
    if (asum && bsum && csum) {
      ans = min(ans, cnt + abs(a - asum) + abs(b - bsum) + abs(c - csum));
    }
  } else {
    for (long long i = 0; i < (long long)(4); ++i) {
      s.push(i);
      dfs();
    }
  }
  s.pop();
}
