#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, o = 0, t = 0, tt = 0;
  cin >> n;
  int arr[n];
  int ar[n], br[n], cr[n];
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  for (int i = 1; i <= n; i++) {
    if (arr[i] == 1) {
      ar[o] = i;
      o++;
    } else if (arr[i] == 2) {
      br[t] = i;
      t++;
    } else {
      cr[tt] = i;
      tt++;
    }
  }
  int x = min(o, min(tt, t));
  cout << x << "\n";
  if (x != 0) {
    for (int i = 0; i < x; i++) {
      cout << ar[i] << " " << br[i] << " " << cr[i] << " "
           << "\n";
    }
  }
  return 0;
}
