#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=0,a,b,c;
int l[MOD];

void solve(int sa, int ga, int sb, int gb, int sc, int gc, int N) {
  if(N == n) {
    if(ga == -1 || gb == -1 || gc == -1) {
      return;
    }
    ans = min(ans, (ll)(abs(sa-a) + ga * 10 + abs(sb-b) + gb * 10 + abs(sc-c) + gc * 10));
    return;
  }
  solve(sa + l[N], ga + 1, sb, gb, sc, gc, N+1);
  solve(sa, ga, sb + l[N], gb + 1, sc, gc, N+1);
  solve(sa, ga, sb, gb, sc + l[N], gc + 1, N+1);
  solve(sa, ga, sb, gb, sc, gc, N+1);
}

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

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

  return 0;
}
