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 MOD = (int)1e9 + 7;
const int MAXN = (int)32;
const int MAXM = 4003;
const int infint = (int)1e9;
int n, a[MAXN], par[2 * MAXN][MAXN][MAXN * MAXN * 2], mat[2 * MAXN][2 * MAXN];
bool dp[2 * MAXN][MAXN][MAXN * MAXN * 2];
int capacity[MAXM][MAXM];
vector<int> G[MAXM];
void add(int u, int v, int w) {
  G[u].push_back(v);
  G[v].push_back(u);
  capacity[u][v] = w;
}
int bfs(int s, int t, vector<int> &par) {
  fill(par.begin(), par.end(), -1);
  par[s] = -2;
  queue<pair<int, int> > q;
  q.push({s, infint});
  while (!q.empty()) {
    int cur = q.front().first, flow = q.front().second;
    q.pop();
    for (auto v : G[cur]) {
      if (par[v] == -1 && capacity[cur][v]) {
        par[v] = cur;
        int new_flow = min(capacity[cur][v], flow);
        if (v == t) return new_flow;
        q.push({v, new_flow});
      }
    }
  }
  return 0;
}
int max_flow(int s, int t) {
  int flow = 0;
  vector<int> par(MAXM);
  int new_flow = 0;
  while (new_flow = bfs(s, t, par)) {
    flow += new_flow;
    int cur = t;
    while (cur != s) {
      int prev = par[cur];
      capacity[prev][cur] -= new_flow;
      capacity[cur][prev] += new_flow;
      cur = prev;
    }
  }
  return flow;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  dp[0][0][0] = 1;
  for (int i = 1; i < 2 * MAXN; i++)
    for (int j = 1; j <= n; j++)
      for (int sum = 0; sum < MAXN * MAXN * 2; sum++)
        if (sum >= max(i * (i - 1) / 2, a[j])) {
          if (dp[i - 1][j][sum - a[j]])
            dp[i][j][sum] = 1, par[i][j][sum] = j;
          else if (dp[i - 1][j - 1][sum - a[j]])
            dp[i][j][sum] = 1, par[i][j][sum] = j - 1;
        }
  int ans = -1;
  for (int i = 1; i < 2 * MAXN; i++)
    if (dp[i][n][i * (i - 1) / 2] && ans == -1) ans = i;
  if (ans == -1) return cout << "=(", 0;
  cout << ans << "\n";
  vector<int> deg;
  int sum = ans * (ans - 1) / 2, cur = n;
  for (int i = ans; i >= 1; i--) {
    deg.push_back(a[cur]);
    int tmp = sum - a[cur];
    cur = par[i][cur][sum];
    sum = tmp;
  }
  int src = 0, pers = 1;
  for (int i = 0; i < ans; i++)
    for (int j = i + 1; j < ans; j++) {
      add(src, pers, 1);
      add(pers, ans * (ans - 1) / 2 + i + 1, 1);
      add(pers, ans * (ans - 1) / 2 + j + 1, 1);
      pers++;
    }
  int sink = pers + ans;
  for (int i = 0; i < ans; i++) add(pers + i, sink, deg[i]);
  max_flow(src, sink);
  pers = 1;
  for (int i = 0; i < ans; i++)
    for (int j = i + 1; j < ans; j++) {
      if (capacity[pers][ans * (ans - 1) / 2 + i + 1] == 0)
        mat[i][j] = 1;
      else
        mat[j][i] = 1;
      pers++;
    }
  for (int i = 0; i < ans; i++) {
    for (int j = 0; j < ans; j++) cout << mat[i][j];
    cout << "\n";
  }
}