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>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
using namespace std;
const int N = 64, M = 32;
bool dp[N][N * N / 2][M];
pair<int, int> par[N][N * N / 2][M];
int a[M];
int g[N][N];
set<pair<int, int> > s;
int vis[N];
void add(int v, int deg) {
  set<pair<int, int> > t;
  memset(vis, 0, sizeof vis);
  while (s.size()) {
    int u = s.rbegin()->second;
    vis[u] = 1;
    int d = s.rbegin()->first;
    s.erase({d, u});
    d--;
    g[u][v] = 1;
    if (d) t.insert({d, u});
  }
  for (int i = 1; i < v; i++) {
    if (vis[i] == 0) {
      g[v][i] = 1;
      deg--;
    }
  }
  s = t;
  if (deg > 0) {
    s.insert({deg, v});
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + n + 1);
  dp[1][a[1]][1] = 1;
  for (int i = 2; i < N; i++) {
    for (int j = i * (i - 1) / 2; j < N * N / 2; j++) {
      for (int k = 1; k <= n; k++) {
        if (j >= a[k] && dp[i - 1][j - a[k]][k] == 1) {
          dp[i][j][k] = 1;
          par[i][j][k] = {j - a[k], k};
        }
        if (j >= a[k] && dp[i - 1][j - a[k]][k - 1] == 1) {
          dp[i][j][k] = 1;
          par[i][j][k] = {j - a[k], k - 1};
        }
      }
    }
  }
  int ras = 0, x = 0, y = 0;
  for (int i = a[1] + 1; i < N; i++) {
    if (dp[i][i * (i - 1) / 2][n] == 1) {
      ras = i;
      x = i * (i - 1) / 2;
      y = n;
      break;
    }
  }
  if (ras == 0) {
    return cout << "=(" << '\n', 0;
    ;
  }
  cout << ras << '\n';
  int ww = ras;
  vector<pair<int, int> > d;
  while (ras != 1) {
    int z = par[ras][x][y].first, t = par[ras][x][y].second;
    d.push_back({a[y], ras});
    x = z, y = t;
    ras--;
  }
  d.push_back({a[1], ras});
  while (d.size()) {
    sort(d.begin(), d.end());
    for (int i = 0; i < d.back().first; i++) {
      g[d.back().second][d[i].second] = 1;
    }
    for (int i = d.back().first; i < d.size() - 1; i++) {
      d[i].first--;
      g[d[i].second][d.back().second] = 1;
    }
    d.pop_back();
  }
  for (int i = 1; i <= ww; i++) {
    for (int j = 1; j <= ww; j++) {
      cout << g[i][j];
    }
    cout << '\n';
  }
}