#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int count1 = 0, count2 = 0, count3 = 0;
  int b[n], c[n], d[n];
  int minl = INT_MIN;
  for (int i = 0; i < n; i++) {
    if (a[i] == 1) {
      count1++;
      b[count1 - 1] = i + 1;
    } else if (a[i] == 2) {
      count2++;
      c[count2 - 1] = i + 1;
    } else {
      count3++;
      d[count3 - 1] = i + 1;
    }
  }
  if (count1 > 0 || count2 > 0 || count3 > 0) {
    minl = min(count3, min(count2, count1));
    cout << minl << endl;
    int j = count1 - minl, k = count2 - minl, l = count3 - minl;
    for (int i = 0; i < minl; i++) {
      cout << b[j] << " " << c[k] << " " << d[l] << endl;
      j++;
      k++;
      l++;
    }
  } else {
    cout << "0" << endl;
  }
  return 0;
}
