#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>

inline void
rep(int n, std::function<void(int)> f) {
    for (int i = 0; i < n; i++) {
        f(i);
    }
};

void myerase(std::vector<int>& v, int e) {
	int tmp = v.at(e);
	v.at(e) = v.back();
	v.pop_back();
}

/*
void printv(std::vector<int>& v) {
	for (const auto& e : v) {
		std::cout << e << ",";
	}
	std::cout << "\n";
}
*/

bool isnmin(std::vector<int> v, int n) {
	for (const auto& e : v) {
		if (e < n) {
			return false;
		}
	}
	return true;
}

template<class T>
void combination(const std::vector<T>& seed, std::vector<int>& takes, int target_size, int& mindis, int target, int& newtake) {
	std::vector<int> indices(target_size);
    const int seed_size = static_cast<int>(seed.size());
    int start_index = 0;
    int size = 0;

	//std::cout << "gattai mindis" << mindis << std::endl;
    while (size >= 0) {
        for (int i = start_index; i < seed_size; ++i) {
            indices[size++] = i;
            if (size == target_size) {
				std::vector<T> comb(target_size);
				int sum = 0;
                for (int x = 0; x < target_size; ++x) {
                    comb[x] = seed[indices[x]];
					sum += seed[indices[x]];
                }
				int dis = std::abs(sum - target);
				std::vector<int> tmp;
				if (dis + (target_size - 1) * 10 < mindis) {
					mindis = dis + (target_size - 1) * 10;
					takes = comb;
					newtake = sum;
				}
                break;
            }
        }
        --size;
        if (size < 0) break;
        start_index = indices[size] + 1;
    }
    
	/*
    for (const auto& e : takes) {
		std::cout << e;
    }
	std::cout << std::endl;
	*/
}

bool gattai(std::vector<int>& v, int length, int& mindis, int min, int& size) {
	int x, y;
	int kazu = mindis / 10;
	int vsize = static_cast<int>(v.size()); 
	int newtake = 0;
	std::vector<int> takes;
	for (int i = 2; i <= kazu; i++) {
		if (i > vsize - min + 1) {
			break;
		}
		std::vector<int> tmpv = v;
		combination(tmpv, takes, i, mindis, length, newtake);
	}
	//std::cout << std::endl;
	
	size = static_cast<int>(takes.size()); 
	if (size > 1) {
		for (const auto &e : takes) {
			int i = 0;
			for (const auto &s : v) {
				if (e == s) {
					myerase(v, i);
					break;
				}
				i++;
			}
		}
		v.push_back(newtake);
		return true;
	}
	return false;
}

int f1(std::vector<int>& v, int length, int mpmax, int min) {
	int i = 0, mindis = 10000, tmpi = 0;
	//printv(v);
	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 (isnmin(v, length)) {
			std::sort(v.begin(), v.end());
			int mp = v.at(0) - length;
			myerase(v, 0);
			return mpmax + mp; 
		}
		if (static_cast<int>(v.size()) > min) {
			int gattaisu = 0;
			if (gattai(v, length, mindis, min, gattaisu)) {
				return f1(v, length, mpmax + (gattaisu - 1) * 10, min);
			}
		}
		//std::cout << "tmpi" << tmpi << '\n'; 
		myerase(v, tmpi);
		return mpmax + mindis;
	}
}

int baka(std::vector<int> v, int x, int y, int z) {
	int mp = 0;
	mp += f1(v, x, 0, 3);
	//std::cout << "mp" << mp << '\n'; 
	mp += f1(v, y, 0, 2);
	//std::cout << "mp" << mp << '\n'; 
	mp += f1(v, z, 0, 1);
	//std::cout << "mp" << mp << '\n'; 
	//std::cout << '\n'; 
	return mp;
}

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.at(0) << '\n'; 
	return 0;
}




Measured memory_bytes: 256