#include <bits/stdc++.h>
const int MAXN = 1e6 + 5;
int n, m;
int a[MAXN];
int b[MAXN];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) scanf("%d", a + i);
  int sm = 0;
  std::vector<int> v1;
  v1.push_back(0);
  v1.push_back(n);
  for (int i = 1; i <= m - 1; ++i) {
    sm += a[i];
    v1.push_back(sm % n);
  }
  sm += a[m];
  std::sort(v1.begin(), v1.end());
  std::vector<int> sz;
  for (int i = 1; i <= (int)v1.size() - 1; ++i) sz.push_back(v1[i] - v1[i - 1]);
  printf("%d\n", (sm + n - 1) / n);
  for (auto x : sz) printf("%d ", x);
  puts("");
  int p = 0;
  for (int i = 1; i <= m; ++i) {
    while (a[i] > 0) {
      a[i] -= sz[p];
      ++p;
      printf("%d ", i);
      if (p == (int)sz.size()) puts(""), p = 0;
    }
  }
  if (p)
    for (int i = p; i <= m - 1; ++i) printf("1 ");
  puts("");
  return 0;
}
