#include <bits/stdc++.h>
using namespace std;
vector<int> ip[10000000];
int n, c[10], ret = 0;
int dlist[12];
int value[4];
int digitMask;
inline void ipsplit(int dcount, int last, int num, string sofar, int val) {
  if (last < dcount && num >= 4) return;
  if (num < 4 && !sofar.empty()) {
    value[num] = val;
    ipsplit(dcount, last, num + 1, "", 0);
  }
  if (last >= dcount) {
    if (num != 4) return;
    ip[ret].resize(4);
    for (int i = 0; i < 4; i++) ip[ret][i] = value[i];
    ret++;
    return;
  }
  int _val = val * 10 + dlist[last];
  if (_val > 255) return;
  sofar += (dlist[last] + '0');
  if (sofar.size() > 1 && sofar[0] == '0') return;
  ipsplit(dcount, last + 1, num, sofar, _val);
}
inline void recurse(int dcount, int low, int high, int mask) {
  if (low > high) {
    if (mask != digitMask) return;
    ipsplit(dcount, 0, 0, "", 0);
    return;
  }
  for (int i = 0; i < n; i++) {
    dlist[low] = dlist[high] = c[i];
    recurse(dcount, low + 1, high - 1, mask | (1 << c[i]));
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &c[i]);
    digitMask |= (1 << c[i]);
  }
  if (n > 6) {
    printf("0\n");
    return 0;
  }
  for (int dcount = 4; dcount <= 12; dcount++)
    recurse(dcount, 0, dcount - 1, 0);
  printf("%d\n", ret);
  for (int i = 0; i < ret; i++) {
    for (int j = 0; j < 4; j++) {
      printf("%d", ip[i][j]);
      if (j == 3)
        printf("\n");
      else
        printf(".");
    }
  }
}
