#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>//priority_queue<型名> 変数：優先度付きキュー　最大値の探索が早い
#include<set>
#include<stack>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<tuple>
#include<utility>
#define rep0(i,n)  for(ll i=0; i<n; i++)
#define rrep0(i,n) for(ll i=n-1; 0<=i; i--)
#define rep1(i,n)  for(ll i=1; i<=n; i++)
#define rrep1(i,n) for(ll i=n; 1<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
using ll = long long;
using namespace std;

int n,a,b,c;  cin >> n >> a >> b >> c;

int calc(vi v,vi l){
  int x = 0,y = 0,z = 0;
  int cnt = 0;
  rep0(i,l.size()){
    if(v[i] == 1){
      if(x != 0 and l[i] != 0){
        cnt++;
      }
      x += l[i];
    }
    if(v[i] == 2){
      if(y != 0 and l[i] != 0){
        cnt++;
      }
      y += l[i];
    }
    if(v[i] == 3){
      if(z != 0 and l[i] != 0){
        cnt++;
      }
      z += l[i];
    }
  }
  return abs(a-x)+abs(b-y)+abs(c-z)+cnt*10;
}

int main(){
  vi l(n);
  rep0(i,n){
    cin >> l[i];
  }
  int ans = INT_MAX;
  for(int i = 0; i < (1 << 2*n); i++){
    vi v(n);
    rep0(j,n){
      v[j] = (i >> j*2) & 3;
    }
    ans = min(ans,calc(v,l));
  }
  cout << ans;
}
