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