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 = 4005;
struct Edge {
  int v, c;
  Edge(int _v, int _c) : v(_v), c(_c) {}
};
vector<Edge> E;
vector<int> g[N];
void addEdge(int u, int v, int c) {
  g[u].emplace_back((int)E.size());
  E.emplace_back(v, c);
  g[v].emplace_back((int)E.size());
  E.emplace_back(u, 0);
}
int S, T;
int d[N];
int p[N];
bool bfs() {
  for (int i = 0; i <= T; ++i) d[i] = -1, p[i] = 0;
  queue<int> q;
  q.push(S);
  d[S] = 0;
  while (q.size()) {
    int u = q.front();
    q.pop();
    for (int i : g[u]) {
      int v = E[i].v;
      if (E[i].c == 0) continue;
      if (d[v] < 0) {
        d[v] = d[u] + 1;
        q.push(v);
      }
    }
  }
  return d[T] >= 0;
}
int dfs(int u, int F) {
  if (u == T || F == 0) return F;
  for (int &i = p[u]; i < (int)g[u].size(); ++i) {
    int j = g[u][i];
    int v = E[j].v;
    if (E[j].c == 0 || d[v] != d[u] + 1) continue;
    int res = dfs(v, min(E[j].c, F));
    if (res) {
      E[j].c -= res;
      j ^= 1;
      E[j].c += res;
      return res;
    }
  }
  return 0;
}
int MaxFlow() {
  while (bfs())
    while (dfs(S, N))
      ;
  int ans = 0;
  for (int i : g[T]) ans += E[i].c;
  return ans;
}
bool f[65][65][2005];
int a[65];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int m = -1;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  sort(a + 1, a + 1 + n);
  for (int P = a[n] + 1; P <= 2 * a[n] + 1; ++P) {
    memset(f, 0, sizeof f);
    f[0][0][0] = 1;
    for (int i = 0; i < P; ++i)
      for (int j = 0; j <= n; ++j)
        for (int s = i * (i - 1) / 2; s <= P * (P - 1) / 2; ++s)
          if (f[i][j][s]) {
            if (j > 0) f[i + 1][j][s + a[j]] = 1;
            ++j;
            if (j <= n) f[i + 1][j][s + a[j]] = 1;
            --j;
          }
    if (f[P][n][P * (P - 1) / 2]) {
      m = P;
      break;
    }
  }
  if (m < 0) {
    cout << "=(";
    return 0;
  }
  int lst = n;
  int sum = m * (m - 1) / 2;
  vector<int> deg = {0};
  for (int i = m - 1; i >= 0; --i) {
    sum -= a[lst];
    deg.emplace_back(a[lst]);
    assert(sum >= i * (i - 1) / 2);
    if (!f[i][lst][sum]) lst--;
  }
  S = 0;
  T = N - 1;
  for (int i = 1; i <= m; ++i)
    if (deg[i]) {
      addEdge(S, i, deg[i]);
      for (int j = 1; j <= m; ++j) {
        int x = i * m + j;
        int y = j * m + i;
        if (i < j) addEdge(i, x, 1), addEdge(x, T, 1);
        if (i > j) addEdge(i, y, 1);
      }
    }
  assert(MaxFlow() == m * (m - 1) / 2);
  vector<vector<int> > adj(m, vector<int>(m, 0));
  for (int i = 0; i < (int)E.size(); i += 2) {
    if (E[i].v == T) continue;
    if (E[i].v <= m) continue;
    if (E[i ^ 1].c) {
      int u = (E[i].v - m - 1) / m;
      int v = (E[i].v - m - 1) % m;
      if (E[i ^ 1].v == v + 1) swap(u, v);
      adj[u][v] = 1;
    }
  }
  cout << m << "\n";
  for (int i = 0; i < m; ++i, cout << "\n")
    for (int j = 0; j < m; ++j) cout << adj[i][j];
}