#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  queue<int> prog, math, sport;
  int n, s;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> s;
    if (s == 1)
      prog.push(i);
    else if (s == 2)
      math.push(i);
    else
      sport.push(i);
  }
  int team_cnt = min(prog.size(), min(math.size(), sport.size()));
  cout << team_cnt << '\n';
  for (int i = 0; i < team_cnt; ++i) {
    cout << prog.front() << " " << math.front() << " " << sport.front() << '\n';
    prog.pop();
    math.pop();
    sport.pop();
  }
  return 0;
}
