#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
using PII = pair<int, int>;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using V = vector<T>;
template <class T>
using V2 = vector<vector<T>>;
template <class T, int W = 255>
using A = array<T, W>;
template <class T, int W = 255, int H = 255>
using A2 = array<array<T, W>, W>;
int n, a, b, c;
V<int> l;
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  cin >> n;
  cin >> c;
  cin >> b;
  cin >> a;
  for (int i = 0; i < static_cast<int>(n); i++) {
    int x;
    cin >> x;
    l.push_back(x);
  }
  std::sort((l).begin(), (l).end(),
            [](const int& x, const int& y) { return x > y; });
  for_each((l).begin(), (l).end(), [](int& a) { cout << a << " "; });
  cout << endl;
  ;
  int mp1 = 0, mp2 = 0, mp3 = 0;
  int ct1 = 0, ct2 = 0, ct3 = 0;
  for (int i = 0; i < static_cast<int>(l.size()); i++) {
    if (a >= l[i] && (ct1 != 0 || l[i] > 10)) {
      a -= l[i];
      mp1 += (ct1 == 0) ? 0 : 10;
      ct1++;
      l[i] = -1;
    } else if (b >= l[i] && (ct2 != 0 || l[i] > 10)) {
      b -= l[i];
      mp2 += (ct2 == 0) ? 0 : 10;
      ct2++;
      l[i] = -1;
    } else if (c >= l[i] && (ct3 != 0 || l[i] > 10)) {
      c -= l[i];
      mp3 += (ct3 == 0) ? 0 : 10;
      ct3++;
      l[i] = -1;
    }
  }
  for (int i = l.size() - 1; i >= 0; i--) {
    if (l[i] == -1) continue;
    if (abs(a - l[i]) + 10 < abs(a)) {
      a -= l[i];
      mp1 += 10;
    } else if (abs(b - l[i]) + 10 < abs(b)) {
      b -= l[i];
      mp2 += 10;
    } else if (abs(c - l[i]) + 10 < abs(c)) {
      c -= l[i];
      mp3 += 10;
    }
  }
  for_each((l).begin(), (l).end(), [](int& a) { cout << a << " "; });
  cout << endl;
  ;
  cout << a << " " << b << " " << c << "\n";
  mp1 += abs(a);
  mp2 += abs(b);
  mp3 += abs(c);
  cout << mp1 + mp2 + mp3 << "\n";
}
