#include <bits/stdc++.h>
int mnm(int x, int y, int z) {
  int mn = 9999, num[3] = {x, y, z};
  for (int i = 0; i < 3; i++) {
    if (mn > num[i]) mn = num[i];
  }
  return mn;
}
int main() {
  int n, i, t, a, b, j = 0, k = 0, r = 0, index1[5001], index2[5001],
                     index3[5001], p[5001];
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &p[i]);
    if (p[i] == 1) {
      index1[j] = i;
      j++;
    } else if (p[i] == 2) {
      index2[k] = i;
      k++;
    } else {
      index3[r] = i;
      r++;
    }
  }
  t = mnm(r, k, j);
  printf("%d\n", t);
  for (i = 0; i < t; i++) {
    printf("%d %d %d\n", index1[i] + 1, index2[i] + 1, index3[i] + 1);
  }
}
