#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long m;
  cin >> n >> m;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<long long> s(n + 1);
  for (int i = 0; i < n; i++) s[i + 1] = (s[i] + a[i]) % m;
  map<long long, long long> C;
  long long ans = 0LL;
  for (int i = 0; i < n; i++) {
    ans += C[s[i]];
    C[s[i]]++;
  }
  cout << ans << endl;
}
