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 maxm = 40;
int a[maxm];
int m;
int dp[maxm][2 * maxm][maxm * maxm * 4];
int res = 0;
int g[2 * maxm][2 * maxm];
struct Node {
  int i, j, k;
  Node(int pi = 0, int pj = 0, int pk = 0) : i(pi), j(pj), k(pk) {}
};
queue<Node> q;
int scores[maxm * 2];
struct SetNode {
  int i, s;
  SetNode(int pi = 0, int ps = 0) : i(pi), s(ps) {}
  bool operator<(SetNode a) const {
    if (s != a.s) return s < a.s;
    return i < a.i;
  }
};
set<SetNode> s;
stack<int> d;
int main() {
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d", a + i);
  }
  sort(a + 1, a + 1 + m);
  memset(dp, -1, sizeof dp);
  dp[0][0][0] = 0;
  q.push(Node(0, 0, 0));
  while (q.size()) {
    Node u = q.front();
    q.pop();
    if (u.i == m) break;
    for (int j = 1; u.k + j * a[u.i + 1] < maxm * 4 * maxm &&
                    u.k + j * a[u.i + 1] >= (u.j + j) * (u.j + j - 1) / 2;
         j++) {
      if (dp[u.i + 1][u.j + j][u.k + j * a[u.i + 1]] != -1) continue;
      dp[u.i + 1][u.j + j][u.k + j * a[u.i + 1]] = j;
      q.push(Node(u.i + 1, u.j + j, u.k + j * a[u.i + 1]));
    }
  }
  bool ok = false;
  for (res = m; res < 2 * maxm; res++) {
    if (dp[m][res][res * (res - 1) / 2] != -1) {
      ok = true;
      break;
    }
  }
  if (!ok)
    puts("=(");
  else {
    printf("%d\n", res);
    int j = res, k = res * (res - 1) / 2;
    int u = 0;
    for (int i = m; i > 0; i--) {
      int cnt = dp[i][j][k];
      j -= cnt;
      k -= cnt * a[i];
      while (cnt) {
        scores[u++] = a[i];
        cnt--;
      }
    }
    for (int i = 0; i < res; i++) {
      if (scores[i]) s.insert(SetNode(i, scores[i]));
    }
    while (s.size()) {
      SetNode u = *s.begin();
      s.erase(u);
      for (int i = 0; i < res; i++) {
        if (!scores[i]) s.insert(SetNode(i, scores[i]));
      }
      for (set<SetNode>::iterator ite = s.begin(); ite != s.end(); ite++) {
        if (g[u.i][ite->i] || g[ite->i][u.i]) continue;
        if (scores[u.i] > 0) {
          g[u.i][ite->i] = 1;
          scores[u.i]--;
        } else if (ite->s > 0) {
          g[ite->i][u.i] = 1;
          scores[ite->i]--;
        }
      }
      s.clear();
      for (int i = 0; i < res; i++) {
        if (scores[i]) s.insert(SetNode(i, scores[i]));
      }
    }
    for (int i = 0; i < res; i++) {
      for (int j = 0; j < res; j++) {
        printf("%d", g[i][j]);
      }
      puts("");
    }
  }
}