#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, a, b, c, ans, tmp;
  cin >> n >> a >> b >> c;
  int l[n] = {};
  vector<int> x(3, 0) ;
  int y[3] = {};
  int i[8] = {};
  for(int k = 0; k < n; k++){
    cin >> l[k];
  }

  for(i[0] = 0; i[0] < 4; i[0]++){
    for(i[1] = 0; i[1] < 4; i[1]++){
      for(i[2] = 0; i[2] < 4; i[2]++){
        for(i[3] = 0; i[3] < 4; i[3]++){
          for(i[4] = 0; i[4] < 4; i[4]++){
            for(i[5] = 0; i[5] < 4; i[5]++){
              for(i[6] = 0; i[6] < 4; i[6]++){
                for(i[7] = 0; i[7] < 4; i[7]++){
                  tmp = 0;
                  x[0] = 0;
                  x[1] = 0;
                  x[2] = 0;
                  y[0] = 0;
                  y[1] = 0;
                  y[2] = 0;
                  for(int j = 0; j < n; j++){
                    if(i[j] == 1){
                      x[0] += l[j];
                      y[0]++;
                      if(y[0]>1){
                        tmp += 10;
                      }
                    }
                    if(i[j] == 2){
                      x[1] += l[j];
                      y[1]++;
                      if(y[1]>1){
                        tmp += 10;
                      }
                    }
                    if(i[j] == 3){
                      x[2] += l[j];
                      y[2]++;
                      if(y[2]>1){
                        tmp += 10;
                      }
                    }
                  }
                  if(x[0]*x[1]*x[2] == 0){
                    break;
                  }
                  sort(x.begin(), x.end());
                  tmp += abs(x[0] - c) + abs(x[1] - b) + abs(x[2] - a);
                  if(ans > tmp){
                    ans = tmp;
                  }
                }
              }
            }
          }
        }
      }
    }
  }

  cout << ans << endl;
  return 0;
}