#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int a[1000000];
  for (int i = 0; i < N; i++) cin >> a[i];
  bool d[100000] = {};
  long long count = 0;
  for (int i = 0; i < N; i++) {
    if (!d[i]) {
      d[i] = true;
      int now = 0;
      int k = 0;
      for (int j = i; j < N; j++) {
        now = (now + a[j]) % M;
        if (now == 0) {
          d[j + 1] = true;
          k++;
          count += k;
        }
      }
    }
  }
  cout << count << endl;
}
