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 + 10, MN = 35;
int dp[2][36][67][2000];
pair<pair<int, int>, pair<int, int> > par[2][36][67][2000];
int n, arr[MN];
bool adj[100][100];
int main() {
  ios_base ::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> arr[i];
  sort(arr, arr + n);
  for (int i = 0; i < 35; ++i)
    for (int j = 0; j < 67; ++j) {
      fill(dp[0][i][j], dp[0][i][j] + 1880, INF);
      fill(dp[1][i][j], dp[1][i][j] + 1880, INF);
    }
  for (int i = 0; i <= 66; ++i)
    dp[0][n][i][i * (i - 1) / 2] = dp[1][n][i][i * (i - 1) / 2] = 0;
  for (int i = n - 1; ~i; --i)
    for (int j = 61; ~j; --j)
      for (int l = j * (j - 1) / 2; l <= 30 * j + 10; ++l) {
        if (l + arr[i] >= j * (j + 1) / 2) {
          if (dp[0][i][j + 1][l + arr[i]] + 1 < dp[1][i][j][l]) {
            dp[1][i][j][l] = dp[0][i][j + 1][l + arr[i]] + 1;
            par[1][i][j][l] = {{0, i}, {j + 1, l + arr[i]}};
          }
          if (dp[0][i][j + 1][l + arr[i]] + 1 < dp[0][i][j][l]) {
            dp[0][i][j][l] = dp[0][i][j + 1][l + arr[i]] + 1;
            par[0][i][j][l] = {{0, i}, {j + 1, l + arr[i]}};
          }
        }
        if (dp[1][i + 1][j][l] < dp[0][i][j][l]) {
          dp[0][i][j][l] = dp[1][i + 1][j][l];
          par[0][i][j][l] = {{1, i + 1}, {j, l}};
        }
      }
  if (dp[1][0][0][0] >= INF) return cout << "=(\n", 0;
  vector<int> d;
  int A = 1, B = 0, C = 0, D = 0;
  int cnt = 0;
  while (B < n) {
    int A1, B1, C1, D1;
    pair<pair<int, int>, pair<int, int> > X = par[A][B][C][D];
    A1 = X.first.first, B1 = X.first.second, C1 = X.second.first,
    D1 = X.second.second;
    if (C1 > C) d.push_back(arr[B]);
    A = A1, B = B1, C = C1, D = D1;
  }
  set<pair<int, int> > S;
  for (int i = 0; i < ((int)(d).size()); ++i) S.insert({d[i], i});
  while (!S.empty()) {
    int v = S.rbegin()->second;
    S.erase(--S.end());
    vector<int> vec;
    for (auto x : S) vec.push_back(x.second);
    for (int i = 0; i < d[v]; ++i) adj[v][vec[i]] = true;
    for (int i = d[v]; i < ((int)(vec).size()); ++i) {
      adj[vec[i]][v] = true;
      S.erase({d[vec[i]], vec[i]});
      d[vec[i]]--;
      S.insert({d[vec[i]], vec[i]});
    }
  }
  cout << ((int)(d).size()) << '\n';
  for (int i = 0; i < ((int)(d).size()); ++i) {
    for (int j = 0; j < ((int)(d).size()); ++j) cout << adj[i][j];
    cout << '\n';
  }
  return 0;
}