#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int count1 = 0, count2 = 0, count3 = 0;
  vector<int> v(n);
  vector<int> v1;
  vector<int> v2;
  vector<int> v3;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    if (v[i] == 1)
      count1++;
    else if (v[i] == 2)
      count2++;
    else
      count3++;
  }
  if (count1 == 0 || count2 == 0 || count3 == 0)
    cout << 0 << endl;
  else {
    int x = min(min(count1, count2), count3);
    cout << x << endl;
    for (int j = 0; j < v.size(); j++) {
      if (v[j] == 1)
        v1.push_back(j + 1);
      else if (v[j] == 2)
        v2.push_back(j + 1);
      else if (v[j] == 3)
        v3.push_back(j + 1);
      if (v1.size() == x && v2.size() == x && v3.size() == x) break;
    }
    for (int i = 0; i < x; i++) {
      cout << v1[i] << " ";
      cout << v2[i] << " ";
      cout << v3[i] << " ";
      cout << endl;
    }
  }
  return 0;
}
