#include <bits/stdc++.h>
using namespace std;
long long int const MOD = 1000000007;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long int n, m;
  cin >> n >> m;
  vector<long long int> a(n + 1);
  for (int i = 1; i < n + 1; i++) {
    cin >> a[i];
  }
  vector<long long int> total(n + 1, 0);
  vector<long long int> tmptotal(n + 1, 0);
  for (int i = 1; i < n + 1; i++) {
    total[i] = total[i - 1] + a[i];
    tmptotal[i] = total[i];
    tmptotal[i] %= m;
  }
  long long int ans = 0;
  multiset<long long int> mst;
  for (int i = n; i > 0; i--) {
    mst.insert(tmptotal[i]);
    ans += mst.count(tmptotal[i - 1]);
  }
  cout << ans << endl;
  return 0;
}
