#include <bits/stdc++.h>
using namespace std;
inline char gc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline long long read() {
  long long x = 0;
  char ch = getchar();
  bool positive = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') positive = 0;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return positive ? x : -x;
}
inline void write(long long a) {
  if (a < 0) {
    a = -a;
    putchar('-');
  }
  if (a >= 10) write(a / 10);
  putchar('0' + a % 10);
}
inline void writeln(long long a) {
  write(a);
  puts("");
}
inline void wri(long long a) {
  write(a);
  putchar(' ');
}
const int N = 1000005;
int cs, n, m, hp[N], q[N], to[N], sum;
int main() {
  n = read(), m = read();
  for (int i = 1; i <= m; i++) sum += (hp[i] = read());
  cs = (sum + n - 1) / n;
  hp[1] += cs * n - sum;
  int dq = 1, dd = 0;
  for (int i = 1; i <= cs; i++) {
    int zs = n;
    while (zs) {
      if (hp[dq] - dd >= zs) {
        dd += zs;
        zs = 0;
      } else {
        zs -= hp[dq] - dd;
        q[++*q] = n - zs;
        dq++;
        dd = 0;
      }
    }
  }
  writeln(cs);
  while (*q <= m) q[++*q] = n;
  sort(&q[1], &q[*q]);
  for (int i = 1; i < *q; i++) {
    to[q[i]] = i;
    wri(i > 1 ? q[i] - q[i - 1] : q[i]);
  }
  puts("");
  dq = 1, dd = 0;
  for (int i = 1; i <= cs; i++) {
    int zs = n, las = 0;
    while (zs) {
      if (hp[dq] - dd >= zs) {
        while (las < m) {
          las++;
          wri(dq);
        }
        dd += zs;
        zs = 0;
      } else {
        zs -= hp[dq] - dd;
        int pos = to[n - zs];
        while (las < pos) {
          las++;
          wri(dq);
        }
        dq++;
        dd = 0;
      }
    }
    puts("");
  }
}
