#include <bits/stdc++.h>
using namespace std;
using P = pair<long long, long long>;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
const long long MOD = 1000000007;
const int INF = 1 << 30;
int choose(int n) { return n * (n - 1) / 2; }
int main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> a(N);
  for (int i = 0; i < N; i++) cin >> a[i];
  vector<long long> s(N + 1, 0);
  for (int i = 0; i < N; i++) s[i + 1] = s[i] + a[i];
  map<long long, long long> mp;
  for (int i = 1; i < N + 1; ++i) mp[s[i] % M]++;
  long long ans = 0;
  for (auto v : mp) {
    ans += choose(v.second);
  }
  ans += mp[0];
  cout << ans << endl;
}
