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 = 64;
const int M = 1900;
struct RecordType {
  int b, c;
} rec[N][32][M];
int dp[N][32][M];
int n;
int arr[N];
bool mydp[M], ans[N][N];
inline bool DP(int x) {
  for (int i = 1; i <= x; i++) memset(dp, 0, sizeof(dp));
  ;
  dp[0][0][0] = 1;
  int Minlose, tmp, totwin = x * (x - 1) / 2, g;
  for (int i = 0; i < x; i++) {
    g = i * (i - 1) / 2;
    tmp = g + (x - i) * i;
    for (int j = 0; j <= min(i, n); j++)
      for (int k = g; k <= tmp; k++)
        if (dp[i][j][k]) {
          Minlose = max(0, k - g - i * (x - i - 1));
          if (j == 0)
            dp[i + 1][1][k + arr[1]] = 1;
          else {
            if (Minlose <= x - 1 - arr[j]) dp[i + 1][j][k + arr[j]] = 1;
            if (Minlose <= x - 1 - arr[j + 1])
              dp[i + 1][j + 1][k + arr[j + 1]] = 1;
          }
        }
  }
  return dp[x][n][totwin];
}
inline void getpath(int x) {
  for (int i = 1; i <= x; i++) memset(dp, 0, sizeof(dp));
  ;
  dp[0][0][0] = 1;
  int Minlose, tmp, totwin = x * (x - 1) / 2, g;
  for (int i = 0; i < x; i++) {
    g = i * (i - 1) / 2;
    tmp = g + (x - i) * i;
    for (int j = 0; j <= min(i, n); j++)
      for (int k = g; k <= tmp; k++)
        if (dp[i][j][k]) {
          Minlose = max(0, k - g - i * (x - i - 1));
          if (j == 0) {
            dp[i + 1][1][k + arr[1]] = 1;
            rec[i + 1][1][k + arr[1]] = (RecordType){0, k};
          } else {
            if (Minlose <= x - 1 - arr[j]) {
              dp[i + 1][j][k + arr[j]] = 1;
              rec[i + 1][j][k + arr[j]] = (RecordType){j, k};
            }
            if (Minlose <= x - 1 - arr[j + 1]) {
              dp[i + 1][j + 1][k + arr[j + 1]] = 1;
              rec[i + 1][j + 1][k + arr[j + 1]] = (RecordType){j, k};
            }
          }
        }
  }
}
inline void solve(int x) {
  int e = n, f = x * (x - 1) / 2;
  RecordType nxt;
  vector<pair<int, int> > vv;
  for (int i = x; i >= 1; i--) {
    vv.push_back(make_pair(f - rec[i][e][f].c, i - 1));
    nxt = rec[i][e][f];
    e = nxt.b;
    f = nxt.c;
  }
  for (int i = 0; i < x; i++) {
    sort(vv.begin(), vv.end());
    pair<int, int> t = vv[0];
    vv.erase(vv.begin());
    for (int j = 0; j < t.first; j++) ans[t.second][vv[j].second] = 1;
    for (int j = t.first; j < (int)vv.size(); j++) {
      ans[vv[j].second][t.second] = 1;
      vv[j].first--;
    }
  }
  printf("%d\n", x);
  for (int i = 0; i < x; i++) {
    for (int j = 0; j < x; j++) printf("%d", ans[i][j]);
    puts("");
  }
}
int main() {
  int sum = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &arr[i]), sum += arr[i];
  if (n == 1 && arr[1] == 0) {
    printf("%d\n%d\n", 1, 0);
    return 0;
  }
  sort(arr + 1, arr + n + 1);
  mydp[0] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < M - arr[i]; j++) mydp[j + arr[i]] |= mydp[j];
  for (int j = M - sum - 1; j >= 0; j--)
    if (mydp[j]) {
      mydp[j + sum] = 1;
      mydp[j] = 0;
    }
  for (int i = n; i <= 61; i++)
    if (mydp[i * (i - 1) / 2] && DP(i)) {
      getpath(i);
      solve(i);
      return 0;
    }
  puts("=(");
  return 0;
}