#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 100;
int n, m;
int hp[N];
vector<int> b;
int s[N];
int main() {
  cin >> n >> m;
  long long sum = 0;
  for (int i = 1; i <= m; i++) {
    scanf("%d", &hp[i]);
    sum += hp[i];
  }
  cout << (sum + n - 1) / n << endl;
  b.push_back(0);
  b.push_back(n);
  for (int i = 1, at = 0; i <= m - 1; i++) {
    at += hp[i];
    at %= n;
    b.push_back(at);
  }
  sort(b.begin(), b.end());
  b.resize(unique(b.begin(), b.end()) - b.begin());
  for (int i = 1; i < b.size(); i++) s[i] = b[i] - b[i - 1];
  for (int i = 1; i <= m; i++) printf("%d ", s[i]);
  printf("\n");
  for (int i = 1; i <= m;) {
    for (int j = 1; j <= m; j++) {
      if (i <= m) {
        hp[i] -= s[j];
      }
      printf("%d ", min(i, m));
      if (hp[i] <= 0 && (i <= m)) {
        i++;
      }
    }
    printf("\n");
  }
  return 0;
}
