#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<long long> A(N + 1), B(N + 1);
  long long cnt = 0;
  for (int i = 1; i <= N; i++) cin >> A[i];
  for (int i = 1; i <= N; i++) B[i] = B[i - 1] + A[i];
  for (int l = 1; l <= N; l++)
    for (int r = l; r <= N; r++)
      if ((B[r] - B[l - 1]) % M == 0) {
        cnt++;
        cout << l << " " << r << endl;
      }
  cout << cnt << endl;
  return 0;
}
