#include <bits/stdc++.h>
using namespace std;
struct node {
  long long v, idx, p;
} c[200005];
bool cmp1(node a, node b) { return a.v < b.v; }
bool cmp2(node a, node b) { return a.idx < b.idx; }
long long n;
long long dp[200005][2];
long long ss[200005][2];
long long run(long long idx, long long s) {
  if (idx == n) {
    if (s == 0) {
      return 0;
    } else
      return 1e17;
  }
  if (dp[idx][s] != -1) return dp[idx][s];
  if (s == 0) {
    long long ans = 1e17;
    if (idx + 2 < n) {
      ans = -c[idx].v + run(idx + 2, 1);
    }
    return dp[idx][s] = ans;
  } else {
    long long ans = 1e17;
    ans = c[idx].v + run(idx + 1, 0);
    long long a2 = (run(idx + 1, 1));
    ss[idx][s] = 1;
    if (a2 < ans) {
      ss[idx][s] = 2;
      ans = a2;
    }
    return dp[idx][s] = ans;
  }
}
int main() {
  memset(dp, -1, sizeof dp);
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> c[i].v;
    c[i].idx = i;
  }
  sort(c, c + n, cmp1);
  long long ans = run(0, 0);
  cout << ans << '\n';
  vector<long long> a;
  long long idx = 1, s = 0;
  long long now = 0;
  a.push_back(++now);
  s = 1;
  long long e = 0;
  e = -c[0].v;
  while (idx < n) {
    if (s == 1) {
      if (ss[idx][s] == 1) {
        a.push_back(now);
        e += c[idx].v;
        idx++;
        s = 0;
      } else {
        a.push_back(now);
        idx++;
      }
    } else {
      e -= c[idx].v;
      now++;
      a.push_back(now);
      a.push_back(now);
      idx += 2;
      s = 1;
    }
  }
  for (long long i = 0; i < n; i++) {
    c[i].p = a[i];
  }
  sort(c, c + n, cmp2);
  cout << now << '\n';
  int co[now + 2];
  memset(co, 0, sizeof co);
  assert(e == ans);
  for (long long i = 0; i < n; i++) {
    cout << c[i].p << ' ';
    co[c[i].p]++;
  }
  for (int i = 1; i <= now; i++) {
    assert(co[i] >= 3);
  }
}
