#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    int t;
    cin >> t;
    a[i] = (a[i - 1] + t) % m;
  }
  sort(a.begin(), a.end());
  long long ret = 0;
  int tmp = 0;
  int crr = -1;
  for (int i = 0; i <= n; i++) {
    if (crr != a[i]) {
      ret += (tmp * (tmp + 1)) >> 1;
      crr = a[i];
      tmp = 0;
    } else {
      tmp++;
    }
  }
  ret += (tmp * (tmp + 1)) >> 1;
  cout << ret << '\n';
  return 0;
}
