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 INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 33;
const int MAXM = 63;
const int MAXS = MAXM * MAXM;
struct aT {
  aT() : id(0), win(0) {}
  bool operator<(const aT &a) const { return id < a.id; }
  int id;
  vector<int> win;
};
int n;
int a[MAXN];
bool dp[MAXM][MAXN][MAXS];
int pre[MAXM][MAXN][MAXS];
bool win[MAXM][MAXM];
void init();
void input();
void work();
void print(int ans);
int main() {
  init();
  input();
  work();
}
void init() { ios::sync_with_stdio(false); }
void input() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
}
void work() {
  sort(a + 1, a + 1 + n);
  dp[0][0][0] = true;
  int ns, ps;
  for (int i = 1; i < MAXM; ++i) {
    ps = (i - 1) * (i - 2) >> 1;
    ns = i * (i - 1) >> 1;
    for (int j = 0; j <= n; ++j) {
      for (int k = ps; k < MAXS; ++k) {
        if (dp[i - 1][j][k]) {
          if (j && (k + a[j]) >= ns)
            dp[i][j][k + a[j]] = true, pre[i][j][k + a[j]] = j;
          if ((j ^ n) && (k + a[j + 1]) >= ns)
            dp[i][j + 1][k + a[j + 1]] = true, pre[i][j + 1][k + a[j + 1]] = j;
        }
      }
    }
    if (dp[i][n][ns]) {
      print(i);
      return;
    }
  }
  printf("=(\n");
}
void print(int ans) {
  printf("%d\n", ans);
  int nk = ans * (ans - 1) >> 1, tk;
  int nj = n;
  vector<pair<int, aT> > ar;
  for (int i = ans; i > 0; --i) {
    ar.push_back(make_pair(a[nj], aT()));
    tk = nk;
    nk -= a[nj];
    nj = pre[i][nj][tk];
  }
  reverse(ar.begin(), ar.end());
  for (int i = 0; i < ans; ++i) ar[i].second.id = i;
  for (int i = 0; i < ans; ++i) {
    sort(ar.begin() + i, ar.end());
    for (int j = 1; j <= ar[i].first; ++j)
      ar[i].second.win.push_back(ar[j + i].second.id);
    for (int j = i + ar[i].first + 1; j < ans; ++j)
      ar[j].second.win.push_back(ar[i].second.id), --ar[j].first;
  }
  for (int i = 0; i < ans; ++i) {
    for (auto x : ar[i].second.win) win[ar[i].second.id][x] = true;
  }
  for (int i = 0; i < ans; ++i) {
    for (int j = 0; j < ans; ++j) putchar(win[i][j] ? '1' : '0');
    putchar('\n');
  }
}