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 = 1e9 + 9;
const long long int MOD = 1e9 + 696969;
const long long INF = 1e18 + 3;
const int C = 1000;
const int D = 2000;
bool dp[2][32][6010];
int opt[1010][32][2010];
int tab[32];
vector<int> v;
int ile[5010], N;
bitset<2010> arr[2010];
pair<int, int> help[2010];
void addEdge(int x, int y) {
  arr[x].set(y, 1);
  ile[x]--;
}
void print(vector<int> v) {
  for (auto u : v) ile[++N] = u;
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j < i; ++j) help[j] = make_pair(ile[j], j);
    sort(help + 1, help + i);
    for (int j = 1; j < i; ++j) {
      if (ile[help[j].second] < ile[i])
        addEdge(i, help[j].second);
      else
        addEdge(help[j].second, i);
    }
  }
  for (int i = (1); i <= (N); ++i) assert(ile[i] == 0);
  for (int i = (1); i <= (N); ++i) {
    for (int j = (1); j <= (N); ++j) cout << arr[i].test(j);
    cout << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  int m;
  cin >> m;
  for (int i = (1); i <= (m); ++i) cin >> tab[i];
  sort(tab + 1, tab + m + 1);
  dp[0][0][0] = 1;
  int res = 6010;
  for (int i = 1; i <= C; ++i) {
    for (int j = 1; j <= m; ++j) {
      for (int nad = 0; nad <= D; ++nad) {
        dp[i & 1][j][nad] = 0;
        dp[i & 1][0][nad] = 0;
        int current_delta = tab[j] - (i - 1);
        if (nad - current_delta >= 0) {
          dp[i & 1][j][nad] |= dp[(i & 1) ^ 1][j][nad - current_delta];
          dp[i & 1][j][nad] |= dp[(i & 1) ^ 1][j - 1][nad - current_delta];
          if (dp[i & 1][j][nad] && dp[(i & 1) ^ 1][j][nad - current_delta])
            opt[i][j][nad] = j;
          if (dp[i & 1][j][nad] && dp[(i & 1) ^ 1][j - 1][nad - current_delta])
            opt[i][j][nad] = j - 1;
        }
        if (nad == 0 && j == m && dp[i & 1][j][nad]) {
          if (i < res) {
            res = i;
          }
        }
      }
    }
    if (i > res) break;
  }
  if (res == 6010) {
    cout << "=(";
    exit(0);
  };
  int nad = 0;
  cout << res << endl;
  int j = m;
  for (int i = res; i > 0; --i) {
    v.push_back(tab[j]);
    if (opt[i][j][nad] == j - 1) {
      nad += (i - 1) - tab[j];
      --j;
    } else {
      nad += (i - 1) - tab[j];
    }
  }
  reverse(v.begin(), v.end());
  print(v);
}