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 = 65, SUM = 2000, oo = 27081993;
int m, a[33], f[77][77][2222], result[77][77];
pair<int, int> teams[2222];
vector<int> scores;
struct edge {
  int x, y, cap, flow;
};
struct DinicFlow {
  int n, S, T;
  vector<vector<int> > a;
  vector<int> cur, d;
  vector<edge> e;
  DinicFlow() {}
  DinicFlow(int n, int S, int T) {
    this->n = n;
    this->S = S;
    this->T = T;
    a = vector<vector<int> >(n + 1);
    cur = vector<int>(n + 1);
    d = vector<int>(n + 1);
  }
  void addEdge(int x, int y, int cap) {
    edge e1 = {x, y, cap, 0};
    edge e2 = {y, x, 0, 0};
    a[x].push_back(e.size());
    e.push_back(e1);
    a[y].push_back(e.size());
    e.push_back(e2);
  }
  int bfs() {
    queue<int> q;
    for (int i = 1; i <= n; i++) d[i] = -1;
    q.push(S);
    d[S] = 0;
    while (!q.empty() && d[T] < 0) {
      int x = q.front();
      q.pop();
      for (int i = 0; i < int(a[x].size()); i++) {
        int id = a[x][i], y = e[id].y;
        if (d[y] < 0 && e[id].flow < e[id].cap) q.push(y), d[y] = d[x] + 1;
      }
    }
    return d[T] >= 0;
  }
  int dfs(int x, int val) {
    if (!val) return 0;
    if (x == T) return val;
    for (; cur[x] < int(a[x].size()); cur[x]++) {
      int id = a[x][cur[x]], y = e[id].y;
      if (d[y] != d[x] + 1) continue;
      int pushed = dfs(y, min(val, e[id].cap - e[id].flow));
      if (pushed) {
        e[id].flow += pushed;
        e[id ^ 1].flow -= pushed;
        return pushed;
      }
    }
    return 0;
  }
  int maxFlow() {
    int res = 0;
    while (bfs()) {
      for (int i = 1; i <= n; i++) cur[i] = 0;
      while (1) {
        int val = dfs(S, oo);
        if (!val) break;
        res += val;
      }
    }
    return res;
  }
};
void trace(int i, int j, int sum) {
  if (!i) return;
  int cnt = f[i][j][sum];
  trace(i - 1, j - cnt, sum - cnt * a[i - 1]);
  while (cnt--) scores.push_back(a[i - 1]);
}
int main() {
  int x;
  cin >> m;
  for (int i = 0; i < m; i++) cin >> a[i];
  sort(a, a + m);
  f[0][0][0] = 1;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < N; j++)
      for (int sum = 0; sum <= SUM; sum++)
        if (f[i][j][sum]) {
          int newSum = sum;
          for (int jj = j + 1; jj <= N; jj++) {
            newSum += a[i];
            if (newSum < jj * (jj - 1) / 2) break;
            f[i + 1][jj][newSum] = jj - j;
          }
        }
  for (int n = 1; n <= N; n++)
    if (f[m][n][n * (n - 1) / 2]) {
      int matches = n * (n - 1) / 2;
      scores.clear();
      trace(m, n, matches);
      int S = matches + n + 1, T = S + 1, matchId = 1;
      DinicFlow flow(T, S, T);
      for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++) {
          teams[matchId] = {i, j};
          flow.addEdge(S, matchId, 1);
          flow.addEdge(matchId, matches + i + 1, 1);
          flow.addEdge(matchId, matches + j + 1, 1);
          matchId++;
        }
      for (int i = 0; i < n; i++) flow.addEdge(matches + i + 1, T, scores[i]);
      int maxFlow = flow.maxFlow();
      if (maxFlow != matches) continue;
      for (auto e : flow.e)
        if (e.x <= matches && e.y > matches && e.y <= matches + n &&
            e.flow == 1) {
          int win = e.y - matches - 1, lose;
          if (win == teams[e.x].first)
            lose = teams[e.x].second;
          else
            lose = teams[e.x].first;
          result[win][lose] = 1;
        }
      cout << n << endl;
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) cout << result[i][j];
        cout << endl;
      }
      return 0;
    }
  cout << "=(" << endl;
}