#include <bits/stdc++.h>
using namespace std;
template <typename Tp>
inline void read(Tp &x) {
  static char c;
  static bool neg;
  x = 0, c = getchar(), neg = false;
  for (; !isdigit(c); c = getchar()) {
    if (c == '-') {
      neg = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (neg) {
    x = -x;
  }
}
const int N = 1e6 + 5;
int n, m;
int hp[N], last[N], diff[N];
int main() {
  read(n), read(m);
  int sum = 0;
  for (int i = 1; i <= m; ++i) {
    read(hp[i]);
    sum += hp[i];
  }
  int res = ceil((double)sum / (double)n);
  printf("%d\n", res);
  for (int i = 1, now = 0; i < m; ++i) {
    now += hp[i];
    last[i] = now % n;
  }
  last[m] = n;
  sort(last + 1, last + m + 1);
  for (int i = 0; i < m; ++i) {
    diff[i] = last[i + 1] - last[i];
  }
  for (int i = 0; i < m; ++i) {
    printf("%d ", diff[i]);
  }
  puts("");
  for (int i = 1, now = 0; i <= m; ++i) {
    while (hp[i] > 0) {
      hp[i] -= diff[now];
      printf("%d ", i);
      ++now;
      if (now == m) {
        now = 0;
        putchar('\n');
      }
    }
    if (i == m && now != 0) {
      while (now != m) {
        putchar('1');
        putchar(' ');
        ++now;
      }
      putchar('\n');
    }
  }
  return 0;
}
