#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  int a[4][5000];
  int u = 0, j = 0, k = 0;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    if (t == 1) a[t][u++] = i + 1;
    if (t == 2) a[t][j++] = i + 1;
    if (t == 3) a[t][k++] = i + 1;
  }
  cout << min(min(u, j), k) << "\n";
  int q = 0, w = 0, e = 0;
  while (q < u && w < j && e < k) {
    cout << a[1][q++] << " " << a[2][w++] << " " << a[3][e++] << "\n";
  }
}
