#include <bits/stdc++.h>
using namespace std;
template <typename TYPE>
void readint(TYPE& x) {
  x = 0;
  int f = 1;
  char c;
  for (c = getchar(); !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  x *= f;
}
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
template <typename... T>
void rd(T&... args) {
  ((cin >> args), ...);
}
template <typename... T>
void ps(T... args) {
  ((cout << args << ' '), ...);
  cout << '\n';
}
const long long MOD = 1e9 + 7, MOD1 = 998244353LL, MAX = 1e5 + 5;
const char nl = '\n';
const int INF = 2e9;
int n;
long long x, y;
void solve() {
  map<long long, long long> m;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> x;
    m[x]++;
  }
  set<pair<long long, long long>> s;
  for (auto it : m) {
    s.insert({it.second, it.first});
  }
  vector<pair<pair<long long, long long>, long long>> v;
  while (s.size() >= 3) {
    long long x1, x2, y1, y2, z1, z2;
    auto xd = s.end();
    xd--;
    x1 = (*xd).first, x2 = (*xd).second;
    s.erase(xd);
    xd = s.end();
    xd--;
    y1 = (*xd).first, y2 = (*xd).second;
    s.erase(xd);
    xd = s.end();
    xd--;
    z1 = (*xd).first, z2 = (*xd).second;
    s.erase(xd);
    if (x1 >= 2) s.insert({--x1, x2});
    if (y1 >= 2) s.insert({--y1, y2});
    if (z1 >= 2) s.insert({--z1, z2});
    long long mx = max(x2, max(y2, z2)), mn = min(x2, min(y2, z2)),
              md = x2 + y2 + z2 - mn - mx;
    v.push_back({{mx, md}, mn});
  }
  cout << v.size() << '\n';
  for (auto it : v)
    cout << it.first.first << ' ' << it.first.second << ' ' << it.second
         << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
  return 0;
}
