#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
long long a[N];
int n, m;
int ans = 0;
map<long long, long long> mp;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  for (int i = 1; i <= n; i++) a[i] += a[i - 1], a[i] %= m;
  mp[0] = 1;
  for (int i = 1; i <= n; i++) {
    if (mp[a[i]] == 0)
      mp[a[i]] = 1;
    else {
      ans = (ans + mp[a[i]]);
      mp[a[i]]++;
    }
  }
  cout << ans;
}
