#include <bits/stdc++.h>
using namespace std;
int n, m, tot, a[1001000], ans[1001000 << 2], k[1001000];
long long s;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) scanf("%d", &a[i]), s += a[i], k[i] = s % n;
  k[m] = n;
  sort(k + 1, k + m + 1);
  for (int i = m; i; i--) k[i] -= k[i - 1];
  for (int i = 1, j = 1; i <= m; ++i) {
    int x = a[i];
    while (x > 0) ans[++tot] = i, x -= k[j], j = j % m + 1;
  }
  while (tot % m) ans[++tot] = 1;
  printf("%d\n", tot / m);
  for (int i = 1; i <= m; ++i) printf("%d ", k[i]);
  puts("");
  for (int i = 1; i <= tot; ++i) {
    printf("%d", ans[i]);
    putchar(i % m ? ' ' : '\n');
  }
  return 0;
}
