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