#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
int take[9];
int abc[3];
int entyou(int a) { return a + 1; }
int tansyuku(int a) { return a - 1; }
int gousei(int a, int b) { return a + b; }
int main() {
  int n, a, b, c;
  cin >> abc[0] >> abc[1] >> abc[2];
  int mp = 0;
  for (int i = 0; i < n; i++) cin >> take[i];
  sort(take, take + n, greater<int>());
  int count = 3;
  int point = 0;
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < n; j++) {
      if (abc[i] == take[j]) {
        count--;
        take[j] = 0, abc[i] = 0;
        break;
      }
    }
  sort(take, take + n, greater<int>());
  sort(abc, abc + 3, greater<int>());
  while (count) {
    if (abc[3 - count] == take[point]) count--;
    if (abs(abc[3 - count] - take[point]) <= 10) {
      while (abc[3 - count] - take[point] == 0) {
        if (abc[3 - count] - take[point] > 0) {
          entyou(take[point]);
          mp++;
        } else {
          tansyuku(take[point]);
          mp++;
        }
      }
      count--;
      point++;
    } else {
      for (int i = point + 1; i < n; i++) {
        if (abc[3 - count] - take[point] >
            abc[3 - count] - take[point] + take[i]) {
          take[point] += take[i];
          take[i] = 0;
          mp += 10;
        }
      }
    }
  }
  cout << mp << endl;
}
