#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<long long> a(n + 1);
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    a[i] = a[i - 1] + x;
    a[i] %= m;
  }
  int ans = 0;
  map<int, int> mp;
  for (int i = 1; i <= n; i++) {
    if (a[i] == 0) ans++;
    ans += mp[a[i]];
    mp[a[i]]++;
  }
  cout << ans << '\n';
  return 0;
}
