#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n];
  vector<int> v1, v2, v3;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    if (arr[i] == 1) {
      v1.push_back(i);
    } else if (arr[i] == 2) {
      v2.push_back(i);
    } else {
      v3.push_back(i);
    }
  }
  int a = min(v1.size(), min(v2.size(), v3.size()));
  cout << a << endl;
  while (a--) {
    cout << v1.back() << " " << v2.back() << " " << v3.back() << endl;
    v1.pop_back();
    v2.pop_back();
    v3.pop_back();
  }
}
