#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int INF = 1001001001;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (long long(i) = 0; (i) < (n); (i)++) cin >> a[i];
  vector<long long> sum(n + 1);
  for (long long(i) = 0; (i) < (n); (i)++) sum[i + 1] = (sum[i] + a[i]) % m;
  map<int, int> cnt;
  for (long long(i) = 0; (i) < (n); (i)++) cnt[sum[i + 1]]++;
  cnt[0]++;
  long long ans = 0;
  for (auto c : cnt) {
    ans += c.second * (c.second - 1) / 2;
  }
  cout << ans << endl;
}
