#include <bits/stdc++.h>
using namespace std;
int n, m, sum, a[1000005], b[1000005];
int main() {
  scanf("%d%d", &n, &m);
  for (register int i = 1; i <= m; ++i) scanf("%d", &a[i]), sum += a[i];
  for (register int i = 1; i <= m; ++i) b[i] = (b[i - 1] + a[i]) % n;
  b[m] = n;
  sort(b + 1, b + m + 1);
  for (register int i = m; i >= 1; --i) b[i] -= b[i - 1];
  printf("%d\n", (sum + n - 1) / n);
  for (register int i = 1; i <= m; ++i) printf("%d ", b[i]);
  printf("\n");
  int j = 1;
  for (register int i = 1; i <= m; ++i)
    while (a[i] > 0) {
      a[i] -= b[j];
      printf("%d ", i);
      if (j % m == 0) printf("\n");
      j = j % m + 1;
    }
  if (j == 1) return 0;
  for (; j <= m; ++j) printf("1 ");
  printf("\n");
  return 0;
}
