#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<long long> x(n);
  for (long long i = 0; i < n; i++) cin >> x[i];
  unordered_map<int, int> m;
  for (auto num : x) {
    m[num]++;
  }
  if (m.size() < 3) {
    cout << 0;
    return 0;
  }
  int ans = INT_MAX;
  for (auto num : m) {
    if (ans > num.second) {
      ans = num.second;
    }
  }
  printf("%d\n", ans);
  vector<vector<int>> v(4);
  for (int i = 0; i < n; i++) {
    if (x[i] == 1) v[1].push_back(i + 1);
    if (x[i] == 2) v[2].push_back(i + 1);
    if (x[i] == 3) v[3].push_back(i + 1);
  }
  for (long long i = 0; i < ans; i++) {
    printf("%d %d %d\n", v[1][i], v[2][i], v[3][i]);
  }
  return 0;
}
