#include <bits/stdc++.h>
const unsigned int M = 1000000007;
template <class T>
const T &Max(T var1, T var2) {
  if (var2 > var1) return var2;
  return var1;
}
template <class T>
const T &Min(T var1, T var2) {
  if (var2 < var1) return var2;
  return var1;
}
template <class T>
long long MaxInRange(const std::vector<T> &collection, long long start = 0,
                     long long end = -1) {
  long long Max = start++;
  if (end == -1 || end > collection.size()) end = collection.size();
  for (; start < end; start++)
    if (collection[start] > collection[Max]) Max = start;
  return Max;
}
template <class T>
long long MinInRange(const std::vector<T> &collection, long long start = 0,
                     long long end = -1) {
  long long Min = start++;
  if (end == -1 || end > collection.size()) end = collection.size();
  for (; start < end; start++)
    if (collection[start] < collection[Min]) Min = start;
  return Min;
}
template <class T>
T Abs(T num) {
  if (num < 0) num *= -1;
  return num;
}
template <class T>
void Swap(T &var1, T &var2) {
  T temp = std::move(var1);
  var1 = std::move(var2);
  var2 = std::move(temp);
}
template <class T>
T MaxDiff(const std::vector<T> &Sortedcollection) {
  T maxdiff = LONG_MIN;
  long long range = Sortedcollection.size() - 1;
  for (long long i = 0; i < range; i++)
    if (Sortedcollection[i + 1] - Sortedcollection[i] > maxdiff)
      maxdiff = Sortedcollection[i + 1] - Sortedcollection[i];
  return maxdiff;
}
template <class T>
T MinDiff(const std::vector<T> &Sortedcollection) {
  T mindiff = LONG_MIN;
  long long range = Sortedcollection.size() - 1;
  for (long long i = 0; i < range; i++)
    if (Sortedcollection[i + 1] - Sortedcollection[i] < mindiff)
      mindiff = Sortedcollection[i + 1] - Sortedcollection[i];
  return mindiff;
}
void PrintYoN(bool YoN) {
  YoN ? std::cout << "YES" << std::endl : std::cout << "NO" << std::endl;
}
template <class T>
T GCD(T a, T b) {
  T Maxx = Max(a, b), Minn = Min(a, b);
  T GCD = 1;
  if (Minn == 0)
    return Maxx;
  else if (a % 2 == b % 2 == 0)
    return 2 * GCD(a / 2, b / 2);
  while (Maxx % Minn != 0) {
    GCD = Maxx % Minn;
    Maxx = Minn;
    Minn = GCD;
  }
  return GCD;
}
template <class T>
T LCM(T a, T b) {
  return a * b / gcd(a, b);
}
template <class T>
T mod(T a, T b, T mod) {
  T res = 0, c = 1;
  return res;
}
int main() {
  int test = 0;
  short n = 0;
  std::cin >> n;
  std::stack<short> prog;
  std::stack<short> PE;
  std::stack<short> math;
  for (int i = 0, j = 0; i < n; i++) {
    std::cin >> j;
    if (j == 1)
      prog.push(i);
    else if (j == 2)
      PE.push(i);
    else
      math.push(i);
  }
  int min = Min(Min(prog.size(), PE.size()), math.size());
  std::cout << min << std::endl;
  for (int i = 0, j = min; i < min; i++, prog.pop(), PE.pop(), math.pop())
    std::cout << prog.top() + 1 << " " << PE.top() + 1 << " " << math.top() + 1
              << std::endl;
  return 0;
}
