#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
const long long mo = 1e9 + 7;
const long long inf = 1e9;
const long long Inf = 1e18;
int a[N], b[N];
int main() {
  int n, m, tot = 0;
  scanf("%d%d", &n, &m);
  int nw = 0;
  for (int i = (1); i <= (m); ++i) {
    scanf("%d", &a[i]);
    int x = a[i];
    if (x <= nw) {
      b[i] = b[i - 1] + x;
      nw -= x;
    } else {
      x -= nw;
      tot += x / n;
      x = x % n;
      b[i] = x;
      if (x)
        nw = n - x, ++tot;
      else
        nw = 0;
    }
  }
  sort(b + 1, b + m);
  b[m] = n;
  for (int i = (m); i >= (1); --i) b[i] = b[i] - b[i - 1];
  printf("%d\n", tot);
  for (int i = (1); i <= (m); ++i) printf("%d ", b[i]);
  printf("\n");
  int x = 1;
  for (int i = (1); i <= (m); ++i) {
    while (a[i] > 0) {
      a[i] -= b[x];
      printf("%d ", i);
      if (x == m)
        x = 1, printf("\n");
      else
        ++x;
    }
  }
  for (; x != 1 && x != m + 1; ++x) printf("%d ", m);
}
