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;
istream& in = cin;
int n, a[50];
void input() {
  in >> n;
  for (int i = 0; i < n; ++i) in >> a[i];
}
int ansnum;
vector<int> ans;
int dp[(70)][(70)][(70) * (70)], pace[(70)][(70)][(70) * (70)];
int dfs(int pos, int num, int sum) {
  if (sum > ansnum * (ansnum - 1) / 2) return 0;
  int& ref = dp[pos][num][sum];
  if (ref != -1) return ref;
  ref = 0;
  if (pos == n || num == ansnum) {
    return ref =
               (sum == ansnum * (ansnum - 1) / 2 && pos == n && num == ansnum);
  }
  for (int k = 1; k <= ansnum - num; ++k) {
    if (sum + k * a[pos] >= (num + k) * (num + k - 1) / 2) {
      pace[pos][num][sum] = k;
      if (dfs(pos + 1, num + k, sum + k * a[pos])) {
        ref = 1;
        break;
      }
    } else
      break;
  }
  return ref;
}
bool cale() {
  for (ansnum = n; ansnum < (70); ++ansnum) {
    memset(dp, -1, sizeof(dp));
    if (ansnum == 4) {
      int t = 0;
    }
    if (dfs(0, 0, 0)) {
      ans.clear();
      int p1, p2, p3;
      p1 = p2 = p3 = 0;
      while (p1 != n) {
        int num = pace[p1][p2][p3];
        for (int k = 1; k <= num; ++k) {
          ans.push_back(a[p1]);
        }
        p2 += num;
        p3 += num * a[p1];
        p1++;
      }
      return 1;
    }
  }
  return 0;
}
int g[(70)][(70)];
bool cmp(pair<int, int> a, pair<int, int> b) {
  if (a.first != b.first)
    return a.first > b.first;
  else
    return a.second < b.second;
}
bool vis[70];
int main() {
  int TEST_CASE = 1;
  while (TEST_CASE-- > 0) {
    input();
    sort(a, a + n);
    if (cale()) {
      memset(g, -1, sizeof(g));
      vector<pair<int, int> > V, P;
      for (int i = 1; i <= ansnum; ++i) g[i][i] = 0;
      assert(ansnum == ans.size());
      for (int i = 0; i < ansnum; ++i) {
        V.push_back(make_pair(ansnum - 1 - ans[i], i + 1));
        P.push_back(make_pair(ans[i], i + 1));
      }
      while (!P.empty()) {
        sort(P.begin(), P.end());
        pair<int, int> top = P.back();
        P.pop_back();
        sort(V.begin(), V.end());
        for (int i = (int)V.size() - 1; i >= 0 && top.first > 0; --i) {
          int p1 = top.second;
          int p2 = V[i].second;
          if (g[top.second][V[i].second] != -1 || vis[V[i].second]) continue;
          g[top.second][V[i].second] = 1;
          g[V[i].second][top.second] = 0;
          V[i].first--;
          top.first--;
        }
        for (int i = 1; i <= ansnum; ++i) {
          if (g[top.second][i] == -1) {
            g[top.second][i] = 0;
            g[i][top.second] = 1;
            for (pair<int, int>& p : P) {
              if (p.second == i) {
                p.first--;
                break;
              }
            }
          }
        }
        vis[top.second] = 1;
      }
      cout << ansnum << endl;
      for (int i = 1; i <= ansnum; ++i) {
        for (int j = 1; j <= ansnum; ++j) {
          printf("%d", g[i][j]);
        }
        putchar('\n');
      }
    } else {
      cout << "=(" << endl;
    }
  }
  return 0;
}