#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000005;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * f;
}
int a[maxn];
int main() {
  int n, m, op, sum = 0;
  n = read(), m = read();
  for (int i = 1; i <= m; i++) {
    a[i] = read();
    sum += a[i];
  }
  int tp = 0;
  if (sum % n == 0) {
    tp = sum / n;
    cout << sum / n << endl;
  } else {
    cout << sum / n + 1 << endl;
    tp = sum / n + 1;
  }
  sum = 0;
  vector<int> k;
  k.push_back(0), k.push_back(n);
  for (int i = 1; i < m; i++) {
    sum += a[i];
    k.push_back(sum % n);
  }
  sort(k.begin(), k.end());
  vector<int> ans;
  for (int i = 1; i < k.size(); i++) {
    ans.push_back(k[i] - k[i - 1]);
  }
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << ' ';
  cout << endl;
  int len = ans.size();
  int ptr = 0;
  for (int i = 1; i <= m; i++) {
    while (a[i] > 0) {
      a[i] -= ans[ptr++];
      printf("%d ", i);
      if (ptr == m) {
        ptr = 0;
        puts("");
      }
    }
  }
  while (ptr && ptr++ != m) cout << m << ' ';
  return 0;
}
