#include <bits/stdc++.h>
using namespace std;
void get(int arr[], int n) {
  vector<int> v1;
  vector<int> v2;
  vector<int> v3;
  map<int, int> m;
  m[1] = 0;
  m[2] = 0;
  m[3] = 0;
  for (int i = 0; i < n; i++) {
    m[arr[i]]++;
    if (arr[i] == 1) {
      v1.push_back(i + 1);
    } else if (arr[i] == 2) {
      v2.push_back(i + 1);
    } else {
      v3.push_back(i + 1);
    }
  }
  int mini = min(m[1], m[2]);
  mini = min(mini, m[3]);
  cout << mini << endl;
  for (int i = 0; i < mini; i++) {
    cout << v1[i] << " " << v2[i] << " " << v3[i] << endl;
  }
}
int main() {
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  get(arr, n);
}
