			if (dis < mindis) {
				mindis = dis;
				x = i;
				y = k;
			}
		}
	}
	v[y] += v[x];
	myerase(v, x);
}

int f1(std::vector<int> &v, int length, int mpmax) {
	int i = 0, mindis = 1000, tmpi;
	for (const auto &e : v) {
		if (length == e) {
			myerase(v, i);
			return mpmax;
		}
		else {
			int dis = std::abs(length - e);
			if (dis <= mindis) {
				mindis = dis;
				tmpi = i;
			}
		}
		i++;
	}
	if (mindis < mpmax + 10) {
		myerase(v, tmpi);
		return mpmax + mindis;
	}
	else {
		if (static_cast<int>(v.size()) > 1) {
			mp10(v, length);
		}
		else {
			return mpmax + std::abs(length - v[0]);
		}
		return f1(v, length, mpmax + 10);
	}
}

int baka(std::vector<int> v, int x, int y, int z) {
	return f1(v, x, 0) + f1(v, y, 0) + f1(v, z, 0);
}

int main() {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	
	int n, a, b, c, l;
	
	std::cin >> n >> a >> b >> c;
	std::cin.ignore();

	std::vector<int> v;
	rep(n, [&](int i) {
			std::cin >> l;
			v.push_back(l);
			});

	std::vector<int> mp;

	mp.push_back(baka(v, a, b, c));
	mp.push_back(baka(v, a, c, b));
	mp.push_back(baka(v, b, a, c));
	mp.push_back(baka(v, b, c, a));
	mp.push_back(baka(v, c, a, b));
	mp.push_back(baka(v, c, b, a));
	std::sort(mp.begin(), mp.end());

	std::cout << mp[0] << '\n'; 
	return 0;
}
