#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX, MOD = 1e9 + 7;
int main() {
  int n, m;
  cin >> n >> m;
  long long a[n];
  cin >> a[0];
  a[0] %= m;
  for (int i = 1; i < n; i++) {
    int x;
    cin >> x;
    a[i] = (a[i - 1] + x) % m;
  }
  sort(a, a + n);
  long long ans = 0;
  int tmp = 0, cnt = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == 0) ans++;
    if (a[i] == tmp)
      cnt++;
    else {
      if (cnt >= 2) {
        ans += cnt * (cnt - 1) / 2;
      }
      cnt = 1;
      tmp = a[i];
    }
  }
  if (cnt >= 2) {
    ans += cnt * (cnt - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
