#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, g1 = 0, g2 = 0, g3 = 0, in, g, t = 0;
  cin >> n;
  vector<pair<int, int>> t1;
  vector<pair<int, int>> t2;
  vector<pair<int, int>> t3;
  for (int x = 0; x < n; x++) {
    cin >> in;
    switch (in) {
      case 1:
        g1++;
        t1.push_back({in, x + 1});
        break;
      case 2:
        g2++;
        t2.push_back({in, x + 1});
        break;
      case 3:
        g3++;
        t3.push_back({in, x + 1});
        break;
    }
  }
  if (g1 && g2 && g3) {
    g = min(min(g1, g2), g3);
    cout << g << endl;
  } else {
    cout << 0;
    return 0;
  }
  for (int z = 0; z < g; z++)
    for (int x = 0; x < n; x++) {
      if (t1[x].first == 1) {
        cout << t1[x].second << " ";
        t1[x].first = 0;
        x = 0;
        t++;
      }
      int e = t2[x].first;
      if (t2[x].first == 2) {
        cout << t2[x].second << " ";
        t2[x].first = 0;
        x = 0;
        t++;
      }
      int s = t3[x].first;
      if (t3[x].first == 3) {
        cout << t3[x].second << " ";
        t3[x].first = 0;
        x = 0;
        t++;
      }
      if (t == 3) {
        t = 0;
        cout << endl;
        break;
      }
    }
  return 0;
}
