#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
int n, m, S, a[N], sp[N];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (int)(1); i <= (int)(m); i++) scanf("%d", &a[i]), S += a[i];
  a[m + 1] = 1 << 30;
  for (int i = (int)(2); i <= (int)(m); i++) sp[i] = (sp[i - 1] + a[i - 1]) % n;
  sort(sp + 1, sp + m + 1);
  sp[m + 1] = n;
  for (int i = (int)(m + 1); i >= (int)(1); i--) sp[i] -= sp[i - 1];
  for (int i = (int)(1); i <= (int)(m); i++) sp[i] = sp[i + 1];
  int pos = 1;
  printf("%d\n", (S - 1) / n + 1);
  for (int i = (int)(1); i <= (int)(m); i++) printf("%d ", sp[i]);
  puts("");
  for (int i = (int)(1); i <= (int)((S - 1) / n + 1); i++) {
    for (int j = (int)(1); j <= (int)(m); j++) {
      for (; !a[pos] && pos < m; ++pos)
        ;
      a[pos] -= sp[j];
      printf("%d ", pos);
    }
    puts("");
  }
}
