Problem: Ivan is reading a book about tournaments. He knows that a tournament is an oriented graph with exactly one oriented edge between each pair of vertices. The score of a vertex is the number of edges going outside this vertex. 

Yesterday Ivan learned Landau's criterion: there is tournament with scores d1 ≤ d2 ≤ ... ≤ dn if and only if <image> for all 1 ≤ k < n and <image>.

Now, Ivan wanna solve following problem: given a set of numbers S = {a1, a2, ..., am}, is there a tournament with given set of scores? I.e. is there tournament with sequence of scores d1, d2, ..., dn such that if we remove duplicates in scores, we obtain the required set {a1, a2, ..., am}? 

Find a tournament with minimum possible number of vertices. 

Input

The first line contains a single integer m (1 ≤ m ≤ 31).

The next line contains m distinct integers a1, a2, ..., am (0 ≤ ai ≤ 30) — elements of the set S. It is guaranteed that all elements of the set are distinct.

Output

If there are no such tournaments, print string "=(" (without quotes).

Otherwise, print an integer n — the number of vertices in the tournament.

Then print n lines with n characters — matrix of the tournament. The j-th element in the i-th row should be 1 if the edge between the i-th and the j-th vertices is oriented towards the j-th vertex, and 0 otherwise. The main diagonal should contain only zeros.

Examples

Input

2
1 2


Output

4
0011
1001
0100
0010


Input

2
0 3


Output

6
000111
100011
110001
011001
001101
000000

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
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[35], pre[35][65][1800], cnt[35], ans[65][65], p[35], ud[35];
bool f[35][65][1800];
int main() {
  int n = read(), tot;
  for (int i = 1; i <= n; i++) a[i] = read();
  sort(a + 1, a + n + 1);
  tot = a[n] * 2 + 1;
  f[0][0][0] = true;
  for (int i = 1; i <= n; i++) {
    for (int j = i - 1; j + n - i + 1 <= tot; j++) {
      int limit = tot * (tot - 1) / 2;
      for (int k = 0; k <= limit; k++) {
        if (f[i - 1][j][k] == false) continue;
        for (int ad = 1; j + ad <= tot && k + ad * a[i] <= limit; ad++) {
          int ul = j + ad, wy = k + ad * a[i];
          if (wy < ul * (ul - 1) / 2) continue;
          pre[i][j + ad][wy] = ad;
          f[i][j + ad][wy] = true;
        }
      }
    }
  }
  int uf = n;
  n = -1;
  for (int i = uf; i <= tot; i++) {
    int ul = i * (i - 1) / 2;
    if (f[uf][i][ul] == true) {
      n = i;
      break;
    }
  }
  if (n == -1)
    printf("=(\n");
  else {
    printf("%d\n", n);
    int wn = uf, wt = n, ws = n * (n - 1) / 2;
    while (wn) {
      int he = pre[wn][wt][ws];
      ud[wn] = he;
      wt -= he, ws -= he * a[wn];
      wn--;
    }
    int now = 0;
    for (int i = 1; i <= uf; i++) {
      for (int j = 1; j <= ud[i]; j++) cnt[++now] = a[i];
    }
    int d = 0;
    for (int i = 1; i <= n; i++) {
      p[i] = i - 1;
      d += abs(p[i] - cnt[i]);
      for (int j = 1; j < i; j++) ans[i][j] = 1;
    }
    while (d) {
      int he = -1, P;
      bool bk = false;
      for (int i = 1; i <= n; i++) {
        if (p[i] < cnt[i] && bk == false) he = p[i], bk = true;
        if (he == -1) continue;
        if (p[i] == he)
          P = i;
        else {
          if (p[i] > cnt[i]) {
            for (int j = 1; j <= n; j++) {
              if (j == i || j == P) continue;
              if (ans[i][j] == 1 && ans[P][j] == 0) {
                swap(ans[i][j], ans[j][i]);
                swap(ans[P][j], ans[j][P]);
                break;
              }
            }
            p[i]--, p[P]++;
            break;
          }
        }
      }
      d -= 2;
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) printf("%d", ans[i][j]);
      printf("\n");
    }
  }
  return 0;
}