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 SIZE = 1e6 + 10;
using namespace std;
struct E {
  int k, c;
  E() {}
  E(int _k, int _c) : k(_k), c(_c) {}
} es[4200010];
struct Flow {
  int n, m, dis[500010];
  int qq[500010], qr, ql;
  vector<int> e[500010];
  void init(int _n) {
    n = _n;
    m = 0;
    for (int i = 0; i < n; i++) e[i] = vector<int>();
  }
  void add_edge(int a, int b, int c) {
    e[a].push_back(m);
    es[m] = E(b, c);
    m++;
    e[b].push_back(m);
    es[m] = E(a, 0);
    m++;
  }
  bool BFS() {
    memset(dis, -1, n * sizeof(int));
    ql = qr = 0;
    qq[qr++] = 0;
    dis[0] = 0;
    while (ql != qr && dis[n - 1] == -1) {
      int p = qq[ql++];
      for (__typeof((e[p]).begin()) it = (e[p]).begin(); it != (e[p]).end();
           it++) {
        E ee = es[*it];
        if (ee.c == 0 || dis[ee.k] != -1) continue;
        dis[ee.k] = dis[p] + 1;
        qq[qr++] = ee.k;
      }
    }
    return dis[n - 1] != -1;
  }
  long long go(int p, long long c) {
    if (p == n - 1) return c;
    long long ret = 0, tmp;
    for (__typeof((e[p]).begin()) it = (e[p]).begin(); it != (e[p]).end();
         it++) {
      E &ee = es[*it];
      if (ee.c == 0 || dis[p] + 1 != dis[ee.k]) continue;
      tmp = go(ee.k, min(c - ret, (long long)ee.c));
      ret += tmp;
      ee.c -= tmp;
      es[(*it) ^ 1].c += tmp;
      if (ret == c) break;
    }
    if (ret == 0) dis[p] = -1;
    return ret;
  }
  long long maxflow() {
    long long ret = 0;
    while (BFS()) ret += go(0, 1LL << 60);
    return ret;
  }
} flow;
int C2[100];
int dp[32][2000][62], a[31];
int rn;
pair<int, int> rd[100000];
char an[65][65];
void go(int m, int ss, int nn) {
  printf("%d\n", nn);
  vector<int> d;
  while (m) {
    int u = dp[m][ss][nn];
    m--;
    for (int i = 0; i < (u); ++i) d.push_back(a[m]);
    ss -= u * a[m];
    nn -= u;
  }
  int n = ((int)(d).size());
  int ed = 1 + C2[((int)(d).size())] + ((int)(d).size());
  flow.init(ed + 1);
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (i); ++j) {
      rn++;
      rd[rn] = make_pair(j, i);
      flow.add_edge(0, rn, 1);
      flow.add_edge(rn, C2[((int)(d).size())] + i + 1, 1);
      flow.add_edge(rn, C2[((int)(d).size())] + j + 1, 1);
    }
  for (int i = 0; i < (((int)(d).size())); ++i) {
    flow.add_edge(C2[((int)(d).size())] + i + 1, ed, d[i]);
  }
  flow.maxflow();
  for (int i = 0; i < (((int)(d).size())); ++i)
    for (int j = 0; j < (((int)(d).size())); ++j) an[i][j] = '0';
  for (int i = 0; i < flow.m; i += 2) {
    int x = es[i + 1].k;
    int y = es[i].k;
    if (x <= C2[((int)(d).size())] && y > C2[((int)(d).size())] && !es[i].c) {
      int from = y - C2[((int)(d).size())] - 1;
      int to = rd[x].first + rd[x].second - from;
      an[y - C2[((int)(d).size())] - 1][to] = '1';
    }
  }
  for (int i = 0; i < (((int)(d).size())); ++i) puts(an[i]);
}
int main() {
  for (int i = 0; i < (100); ++i) C2[i] = i * (i - 1) / 2;
  int(m);
  scanf("%d", &m);
  for (int i = 0; i < (m); ++i) scanf("%d", &(a[i]));
  sort(a, a + m);
  dp[0][0][0] = 1034567890;
  for (int i = 0; i < (m); ++i) {
    int r = m - i - 1;
    for (int ss = 0; ss < (2000); ++ss)
      for (int nn = 0; nn < (62); ++nn) {
        if (!dp[i][ss][nn]) continue;
        int now_ss = ss;
        for (int k = 1; k + nn + r <= 61; k++) {
          now_ss += a[i];
          if (now_ss >= C2[k + nn]) {
            dp[i + 1][now_ss][k + nn] = k;
          } else
            break;
        }
      }
  }
  for (int i = 1; i <= 61; i++) {
    if (dp[m][C2[i]][i]) {
      go(m, C2[i], i);
      return 0;
    }
  }
  return 0 * puts("=(");
}