#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
int n, m;
long long sum;
int hp[maxn], rem[maxn];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &hp[i]);
    sum += hp[i];
    rem[i] = sum % n;
  }
  rem[m] = n;
  sort(rem + 1, rem + m + 1);
  for (int i = m; i >= 0; i--) rem[i] -= rem[i - 1];
  printf("%lld\n", (sum - 1) / n + 1);
  for (int i = 1; i <= m; i++) printf("%d%c", rem[i], (i == m ? '\n' : ' '));
  int cur = 1;
  for (int i = 1; i <= m; i++) {
    int now = hp[i];
    while (now > 0) {
      now -= rem[cur++];
      printf("%d%c", i, (cur > m ? '\n' : ' '));
      if (cur > m) cur = 1;
    }
  }
  while (cur > 1 && cur <= m) {
    printf("1%c", (cur == m ? '\n' : ' '));
    cur++;
  }
}
