#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, arr[5000], v[3][5000], a = 0, b = 0, c = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (int i = 0; i < n; i++) {
    if (arr[i] == 1) {
      v[0][a] = i;
      a++;
    } else if (arr[i] == 2) {
      v[1][b] = i;
      b++;
    } else if (arr[i] == 3) {
      v[2][c] = i;
      c++;
    }
  }
  if (a == 0 || b == 0 || c == 0)
    cout << "0";
  else {
    int x = min(a, b);
    int y = min(x, c);
    cout << y << endl;
    for (int i = 0; i < y; i++) {
      cout << v[0][i] + 1 << " " << v[1][i] + 1 << " " << v[2][i] + 1 << endl;
    }
  }
}
