#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int n, a, b, c;
int l[10];
int ans = 10e7;

void dfs(int x, int y, int z, int d, int i) {
  if(i==n) {
    if(x==0 || y==0 || z==0) return;
    int key = abs(a-x) + abs(b-y) + abs(c-z) + 10*(d-3);
    ans = min(ans, key);
    return;
  }
  dfs(x,y,z,d,i+1);
  dfs(x+l[i],y,z,d+1,i+1);
  dfs(x,y+l[i],z,d+1,i+1);
  dfs(x,y,z+l[i],d+1,i+1);
}

int main() {
  cin >> n >> a >> b >> c;
  rep(i,n) cin >> l[i];
  dfs(0,0,0,0,0);
  cout << ans << endl;
  return 0;
}