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