#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long f = 1, x = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
void write(long long x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
const int MAXN = 1e6 + 5;
int n, m, h[MAXN], k[MAXN], s[MAXN];
int main() {
  ios::sync_with_stdio(0);
  n = read();
  m = read();
  for (int i = 1; i <= m; ++i) h[i] = read();
  int sum = 0;
  for (int i = 1; i < m; ++i) {
    sum += h[i];
    k[i] = sum % n;
  }
  k[m] = n;
  sort(k + 1, k + m + 1);
  for (int i = 1; i <= m; ++i) {
    s[i] = k[i] - k[i - 1];
  }
  int t = 0, cur = 1;
  vector<int> a;
  for (int i = 1; i <= m; ++i) {
    while (h[i] > 0) {
      a.push_back(i);
      h[i] -= s[cur++];
      if (cur == m + 1) cur = 1, t++;
    }
  }
  if (cur != 1) t++;
  while (a.size() % m != 0) a.push_back(1);
  write(t);
  puts("");
  for (int i = 1; i <= m; ++i) write(s[i]), putchar(' ');
  puts("");
  for (int i = 0; i < (int)a.size(); ++i) {
    write(a[i]), putchar(' ');
    if (i % m == m - 1) puts("");
  }
  return 0;
}
