#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long a[10005];
long long ans;
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++)
    for (int j = i; j < n; j++) {
      long long sum = 0;
      for (int k = i; k <= j; k++) sum += a[k];
      if (sum % m == 0) ans++;
      cout << i << " " << j << " " << ans << endl;
    }
  cout << ans;
  return 0;
}
