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;
template <class T>
void dumpBetween(const T& a, const T& b) {
  for (T it = a; it != b; it++) cout << *it << " ";
  cout << endl;
}
template <class T>
void dumpAll(const T& a) {
  dumpBetween((a).begin(), (a).end());
}
template <class T>
void minify(T& a, const T& b) {
  if (a > b) a = b;
}
template <class T>
void maxify(T& a, const T& b) {
  if (a < b) a = b;
}
const int N = 33;
int dp[35][70][3000];
int n;
int a[N];
int solve() {
  for (int j = 1; j < ((int)70); j++) {
    int i = 0;
    int k = j * a[0];
    if (k >= j * (j - 1) / 2) {
      dp[0][j][j * a[0]] = j;
      if (i == n - 1 && k == j * (j - 1) / 2 && dp[i][j][k] > 0) {
        return j;
      }
    }
  }
  for (int i = 1; i < ((int)n); i++) {
    for (int j = 1; j < ((int)70); j++) {
      for (int k = j * (j - 1) / 2; k < ((int)3000); k++) {
        int prev = k - a[i];
        if (prev >= 0) {
          if (dp[i - 1][j - 1][prev] > 0) {
            dp[i][j][k] = 1;
          } else if (dp[i][j - 1][prev] > 0) {
            dp[i][j][k] = dp[i][j - 1][prev] + 1;
          }
        }
        if (i == n - 1 && k == j * (j - 1) / 2 && dp[i][j][k] > 0) {
          return j;
        }
      }
    }
  }
  return 0;
}
vector<int> exemplifyDegrees(int j) {
  int i = n - 1;
  int rest = j * (j - 1) / 2;
  vector<int> ret;
  while (true) {
    int curCount = dp[i][j][rest];
    assert(curCount > 0);
    for (int _108 = 0; _108 < ((int)curCount); _108++) {
      ret.push_back(a[i]);
      rest -= a[i];
      j -= 1;
    }
    assert(rest >= 0);
    if (i == 0) {
      assert(rest == 0);
      return ret;
    }
    i--;
  }
}
int winsSoFar[80];
int lossesSoFar[80];
char output[80][80];
int main() {
  scanf("%d", &(n));
  for (int i = 0; i < ((int)n); i++) scanf("%d", &(a[i]));
  sort(a, a + n);
  int j = solve();
  if (j == 0) {
    puts("=(");
  } else {
    vector<int> degs = exemplifyDegrees(j);
    sort((degs).begin(), (degs).end());
    int s = degs.size();
    printf("%d\n", s);
    for (int i = 0; i < ((int)s); i++) {
      output[i][i] = '0';
    }
    for (int i = 0; i < ((int)s); i++) {
      vector<int> later;
      for (int j = i + 1; j < ((int)s); j++) {
        later.push_back(j);
      }
      sort((later).begin(), (later).end(), [&](int j1, int j2) {
        return (s - 1 - degs[j1] - lossesSoFar[j1]) >
               (s - 1 - degs[j2] - lossesSoFar[j2]);
      });
      int neededWins = degs[i] - winsSoFar[i];
      for (int jj = 0; jj < later.size(); jj++) {
        int j = later[jj];
        if (jj < neededWins) {
          assert(lossesSoFar[j] < s - 1 - degs[j]);
          output[i][j] = '1';
          output[j][i] = '0';
          winsSoFar[i]++;
          lossesSoFar[j]++;
        } else {
          assert(winsSoFar[j] < degs[j]);
          output[i][j] = '0';
          output[j][i] = '1';
          winsSoFar[j]++;
          lossesSoFar[i]++;
        }
      }
      puts(output[i]);
    }
  }
}