#include <bits/stdc++.h>
using namespace std;
int n, a[5030], b, r, s, m, v[5020], c[5020], z[5020], k, l, o, h;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    h = i;
    cin >> a[i];
    if (a[i] == 1) {
      b++;
      v[k] += i + 1;
      k++;
    } else if (a[i] == 2) {
      r++;
      c[l] += i + 1;
      l++;
    } else {
      s++;
      z[o] += i + 1;
      o++;
    }
    i = h;
  }
  m = min(b, min(r, s));
  cout << m << endl;
  for (int j = 0; j < m; j++) {
    cout << v[j] << ' ' << c[j] << ' ' << z[j] << endl;
  }
  return 0;
}
