#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[5001], b[5001], c[5001], d[5001], k = 0, m = 0, f = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] == 1) {
      k++;
      b[k] = i;
    }
    if (a[i] == 2) {
      m++;
      c[m] = i;
    }
    if (a[i] == 3) {
      f++;
      d[f] = i;
    }
  }
  if (k == 0 || m == 0 || f == 0) {
    cout << 0;
    return 0;
  }
  cout << min(k, min(m, f)) << endl;
  while (k > 0 && m > 0 && f > 0) {
    cout << b[k] << " " << c[m] << " " << d[f] << endl;
    k--;
    m--;
    f--;
  }
}
