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 long double pi = 3.1415926535897932384626433832795l;
template <typename T>
inline auto sqr(T x) -> decltype(x * x) {
  return x * x;
}
template <typename T1, typename T2>
inline bool umx(T1& a, T2 b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T1, typename T2>
inline bool umn(T1& a, T2 b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
const int N = 35;
int d[2 * N][N][4 * N * N];
tuple<int, int, int> pr[2 * N][N][4 * N * N];
int a[N];
int n;
int res[2 * N][2 * N];
bool is[2 * N][2 * N];
bool use[2 * N];
int need[2 * N];
void rest(vector<int> ans) {
  memset(is, 0, sizeof(is));
  for (int i = int(0); i < int(((int)(ans).size())); ++i) {
    need[i] = ans[i];
    ans[i] = ((int)(ans).size()) - 1 - ans[i];
  }
  for (int i = int(0); i < int(((int)(ans).size())); ++i) {
    int minn = 1e9, mini = -1;
    for (int j = int(0); j < int(((int)(ans).size())); ++j) {
      if (use[j]) continue;
      if (umn(minn, ans[j])) {
        mini = j;
      }
    }
    use[mini] = 1;
    vector<pair<int, int> > help;
    int cnt = need[mini];
    for (int j = int(0); j < int(((int)(ans).size())); ++j) {
      if (!cnt) break;
      if (j == mini) continue;
      if (use[j]) {
        if (!is[mini][j]) {
          cnt--;
          is[mini][j] = is[j][mini] = 1;
          res[mini][j] = 1;
          res[j][mini] = 0;
        }
      } else {
        help.push_back(make_pair(ans[j], j));
      }
    }
    sort((help).begin(), (help).end());
    reverse((help).begin(), (help).end());
    for (int j = int(0); j < int(cnt); ++j) {
      int idx = help[j].second;
      ans[idx]--;
      is[mini][idx] = is[idx][mini] = 1;
      res[mini][idx] = 1;
      res[idx][mini] = 0;
    }
  }
}
int main() {
  cout.setf(ios::showpoint | ios::fixed);
  cout.precision(20);
  cin >> n;
  for (int i = int(0); i < int(n); ++i) cin >> a[i];
  sort(a, a + n);
  d[0][0][0] = true;
  pr[0][0][0] = make_tuple(-1, -1, -1);
  vector<int> ans;
  for (int i = int(0); i < int(2 * N); ++i) {
    for (int j = 0; j <= n; ++j) {
      for (int sum = 0; sum < 4 * N * N; ++sum) {
        if (!d[i][j][sum]) {
          pr[i][j][sum] = make_tuple(-1, -1, -1);
          continue;
        }
        if (i + 1 == 2 * N) continue;
        if (j < n) {
          int res = sum + a[j] - i;
          if (res >= 0 && res < 4 * N * N) {
            d[i + 1][j + 1][res] = 1;
            pr[i + 1][j + 1][res] = make_tuple(i, j, sum);
          }
        }
        if (j) {
          int res = sum + a[j - 1] - i;
          if (res < 0 || res >= 4 * N * N) continue;
          d[i + 1][j][res] = 1;
          pr[i + 1][j][res] = make_tuple(i, j, sum);
        }
      }
    }
    if (i > 0 && d[i][n][0]) {
      tuple<int, int, int> cur = make_tuple(i, n, 0);
      while (1) {
        ;
        tuple<int, int, int> nxt = pr[get<0>(cur)][get<1>(cur)][get<2>(cur)];
        if (get<0>(nxt) < 0) {
          break;
        }
        if (get<0>(nxt) != get<0>(cur)) {
          ans.push_back(a[get<1>(cur) - 1]);
        }
        cur = nxt;
      };
      rest(ans);
      printf("%d\n", ((int)(ans).size()));
      for (int i1 = int(0); i1 < int(((int)(ans).size())); ++i1) {
        for (int j1 = int(0); j1 < int(((int)(ans).size())); ++j1) {
          printf("%d", res[i1][j1]);
        }
        puts("");
      }
      return 0;
    }
  }
  puts("=(");
  return 0;
}