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;
const int N = 62;
int n, a[N];
int f[N][N][N * N];
int last[N][N][N * N][2];
int e[N][N], s[N], u[N], has;
void out() {
  for (int i = 1; i <= has; i++) {
    for (int j = 1; j <= has; j++) printf("%d", e[i][j]);
    printf("\n");
  }
}
pair<int, int> px[N];
int tu[N];
bool same() {
  memcpy(tu, u, sizeof u);
  sort(tu + 1, tu + 1 + n);
  for (int i = 1; i <= has; i++)
    if (tu[i] != s[i]) return 0;
  return 1;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + 1 + n);
  f[0][0][0] = 1;
  int ans = 0;
  has = 0;
  for (int i = 0; i < 62; i++) {
    if (f[i][n][i * (i - 1) / 2] && a[n] < i) {
      has = i;
      break;
    }
    for (int j = 0; j <= n; j++) {
      for (int s = (i - 1) * i / 2; s <= 30 * i; s++)
        if (f[i][j][s]) {
          if (j != 0) {
            f[i + 1][j][s + a[j]] = 1;
            last[i + 1][j][s + a[j]][0] = j;
            last[i + 1][j][s + a[j]][1] = s;
          }
          f[i + 1][j + 1][s + a[j + 1]] = 1;
          last[i + 1][j + 1][s + a[j + 1]][0] = j;
          last[i + 1][j + 1][s + a[j + 1]][1] = s;
        }
    }
  }
  if (has == 0)
    printf("=(");
  else {
    cout << has << endl;
    int g1 = n, g2 = has * (has - 1) / 2;
    for (int i = has; i; i--) {
      s[i] = g2 - last[i][g1][g2][1];
      int gg1 = g1, gg2 = g2;
      g1 = last[i][gg1][gg2][0];
      g2 = last[i][gg1][gg2][1];
    }
    int dis = 0;
    for (int i = 1; i <= has; i++) {
      for (int j = 1; j < i; j++) e[i][j] = 1;
      u[i] = i - 1;
      dis += abs(s[i] - u[i]);
    }
    for (; dis; dis -= 2) {
      for (int i = 1; i <= has; i++) px[i] = make_pair(u[i], i);
      sort(px + 1, px + 1 + has);
      for (int i = 1; i <= has; i++)
        if (s[i] > px[i].first) {
          for (int j = i + 1; j <= has; j++)
            if (s[j] < px[j].first) {
              for (int z = 1; z <= has; z++) {
                if (e[px[j].second][px[z].second] &&
                    e[px[z].second][px[i].second]) {
                  e[px[j].second][px[z].second] ^= 1,
                      e[px[z].second][px[j].second] ^= 1;
                  e[px[i].second][px[z].second] ^= 1,
                      e[px[z].second][px[i].second] ^= 1;
                  u[px[j].second]--;
                  u[px[i].second]++;
                  break;
                }
              }
              break;
            }
          break;
        }
    }
    sort(u + 1, u + 1 + has);
    for (int i = 1; i <= has; i++) {
      for (int j = 1; j <= has; j++) printf("%d", e[i][j]);
      printf("\n");
    }
  }
}