#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <random>
#include <fstream>
#include <time.h>
// #define int long long
#define debug(x) cerr << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1000000007;
const ll LINF = 1e18;
const double EPS = 1e-9;


ll ans = LINF;
int n,a,b,c;
int l[MOD];
void solve(P A, P B, P C, int N) {
  if(N == n) {
    if(A.first == -1 || B.first == -1 || C.first == -1) {
      return;
    }
    ans = min(ans, (ll)(abs(A.first-a) + A.second * 10 + abs(B.first-b) + B.second * 10 + abs(C.first-c) + C.second * 10));
  }
  solve(make_pair(A.first + l[N], A.second + 1), B, C, N+1);
  solve(A, make_pair(B.first + l[N], B.second + 1), C, N+1);
  solve(A, B, make_pair(C.first + l[N], C.second + 1), N+1);
  solve(A, B, C, N+1);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin>>n>>a>>b>>c;
  rep(i,n) cin>>l[i];
  solve(make_pair(0,-1), make_pair(0,-1), make_pair(0,-1), 0);
  cout << ans << endl;

  return 0;
}
