#include <bits/stdc++.h>
using namespace std;
long long n, m, u, v, op = 1, sum;
long long hp[1000005], num[1000005], da[1000005];
inline long long read() {
  long long f = 1;
  long long ans = 0;
  char t;
  t = getchar();
  while (t < '0' || t > '9') {
    if (t == '-') f = -f;
    t = getchar();
  }
  while (t >= '0' && t <= '9') {
    ans = (ans << 3) + (ans << 1) + (t ^ '0');
    t = getchar();
  }
  return ans * f;
}
inline void write(long long a) {
  if (a < 0) a = -a, putchar('-');
  if (a > 9) write(a / 10);
  putchar(a % 10 + '0');
  return;
}
long long ksm(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = ret * a % 998244353;
    a = a * a % 998244353;
    b = b >> 1;
  }
  return ret;
}
long long ssm;
signed main() {
  n = read();
  m = read();
  for (long long i = 1; i <= m; i++) hp[i] = read(), sum += hp[i];
  for (long long i = 1; i < m; i++) ssm += hp[i], num[i] = ssm % n;
  num[m] = n;
  sort(num + 1, num + m + 1);
  for (long long i = 1; i <= m; i++) da[i] = num[i] - num[i - 1];
  long long tim = ceil(1.0 * sum / n);
  cout << tim << endl;
  for (long long i = 1; i <= m; i++) cout << da[i] << ' ';
  cout << endl;
  long long now = 1, l = 0;
  while ((now <= m)) {
    hp[now] -= da[l + 1];
    cout << now << ' ';
    l++;
    if (l == m) {
      l = 0;
      cout << endl;
      tim--;
    }
    if (hp[now] <= 0) now++;
  }
  if (tim) {
    for (long long i = l + 1; i <= m; i++) cout << m << ' ';
    cout << endl;
  }
  return 0;
}
