#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
int n, m, h[N], sum = 0;
vector<int> s, chs, ans;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &h[i]), sum = (h[i] + sum) % n;
    if (i < m) s.push_back(sum);
  }
  s.push_back(0), s.push_back(n), sort(s.begin(), s.end());
  for (int i = 0; i < s.size() - 1; i++) chs.push_back(s[i + 1] - s[i]);
  for (int i = 1, j = 0; i <= m; i++) {
    for (; h[i] > 0;) ans.push_back(i), h[i] -= chs[j], j = (j + 1) % m;
  }
  for (; ans.size() % m;) ans.push_back(1);
  printf("%d\n", ans.size() / m);
  for (int i = 0; i < m; i++) printf("%d ", chs[i]);
  puts("");
  for (int i = 0; i < ans.size(); i++) {
    printf("%d ", ans[i]);
    if (i % m == m - 1) puts("");
  }
  return 0;
}
