#include <bits/stdc++.h>
inline long long rd() {
  long long _x = 0;
  int _ch = getchar(), _f = 1;
  for (; !isdigit(_ch) && (_ch != '-') && (_ch != EOF); _ch = getchar())
    ;
  if (_ch == '-') {
    _f = 0;
    _ch = getchar();
  }
  for (; isdigit(_ch); _ch = getchar()) _x = _x * 10 + _ch - '0';
  return _f ? _x : -_x;
}
void write(long long _x) {
  if (_x >= 10)
    write(_x / 10), putchar(_x % 10 + '0');
  else
    putchar(_x + '0');
}
inline void wrt(long long _x, char _p) {
  if (_x < 0) putchar('-'), _x = -_x;
  write(_x);
  if (_p) putchar(_p);
}
int n, m, sum, a[1000005], b[1000005], d[1000005];
int main() {
  n = rd(), m = rd();
  for (int i = 1; i <= m; i++) {
    a[i] = rd(), sum += a[i];
  }
  if (sum % n != 0) a[1] += n - sum % n;
  sum = 0;
  for (int i = 1; i <= m; i++) {
    sum += a[i];
    b[i] = sum % n;
  }
  b[m] = n;
  std::sort(b + 1, b + 1 + m);
  wrt(sum / n, '\n');
  for (int i = 1; i <= m; i++) {
    d[i] = b[i] - b[i - 1];
    wrt(d[i], ' ');
  }
  putchar('\n');
  int cnt = 0, pos = 1;
  for (int i = 1; i <= m; i++) {
    for (;; pos = pos % m + 1) {
      if (a[i] <= 0) break;
      cnt++;
      a[i] -= d[pos];
      wrt(i, ' ');
      if (cnt % m == 0) putchar('\n');
    }
  }
}
