#include <bits/stdc++.h>
using namespace std;
long long n, m, ans = 0;
const int maxn = 1e5 + 5;
long long x[maxn], pre[maxn];
int main() {
  map<long long, long long> mp;
  cin >> n >> m;
  pre[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> x[i];
    pre[i] = (pre[i - 1] + x[i]) % m;
    ans += mp[pre[i]];
    mp[pre[i]]++;
  }
  cout << ans + mp[0] << endl;
  return 0;
}
