#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool upmin(T &x, T y) {
  return y < x ? x = y, 1 : 0;
}
template <typename T>
inline bool upmax(T &x, T y) {
  return x < y ? x = y, 1 : 0;
}
const long double eps = 1e-11;
const long double pi = acos(-1);
const int oo = 1 << 30;
const long long loo = 1ll << 62;
const int MAXN = 1000005;
const long long INF = 1ll << 60;
inline int read() {
  int f = 1, x = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + (c ^ 48);
    c = getchar();
  }
  return x * f;
}
vector<int> Ans;
int a[MAXN], b[MAXN], s[MAXN];
int main() {
  int n = read(), m = read(), sum = 0;
  b[1] = n;
  for (int i = 1; i <= m; i++) sum += (a[i] = read()), b[i + 1] = sum % n;
  sort(b + 1, b + m + 1);
  for (int i = 1; i <= m; i++) s[i] = b[i] - b[i - 1];
  for (int i = 1, id = 0; i <= m; i++) {
    int t = a[i];
    while (t > 0) Ans.push_back(i), t -= s[id % m + 1], id++;
  }
  printf("%d\n", (sum - 1) / n + 1);
  while (Ans.size() % m) Ans.push_back(1);
  for (int i = 1; i <= m; i++) printf("%d%c", s[i], " \n"[i % m == 0]);
  for (int i = 0; i < Ans.size(); i++)
    printf("%d%c", Ans[i], " \n"[(i + 1) % m == 0]);
  return 0;
}
