#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long LLINF = 1LL << 60;
class mint {
  long long x;

 public:
  mint(long long x = 0) : x((x % MOD + MOD) % MOD) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint& a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint& a) {
    if ((x += MOD - a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint& a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint& a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint& a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint& a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }
  mint inv() const { return pow(MOD - 2); }
  mint& operator/=(const mint& a) { return (*this) *= a.inv(); }
  mint operator/(const mint& a) const {
    mint res(*this);
    return res /= a;
  }
  friend ostream& operator<<(ostream& os, const mint& m) {
    os << m.x;
    return os;
  }
};
int main() {
  int N;
  long long M;
  cin >> N >> M;
  long long A[N];
  for (int i = 0; i < (int)(N); i++) cin >> A[i];
  vector<long long> sum(N, 0);
  sum[0] = A[0];
  for (int i = 1; i < N; ++i) sum[i] = sum[i - 1] + A[i];
  for (int i = 0; i < (int)(N); i++) sum[i] %= M;
  map<int, int> m;
  for (int i = 0; i < (int)(N); i++) ++m[sum[i]];
  long long ans = 0;
  for (auto iter = begin(m); iter != end(m); ++iter) {
    if (iter->first % M == 0)
      ans += (iter->second) * (iter->second + 1) / 2;
    else
      ans += (iter->second) * (iter->second - 1) / 2;
  }
  cout << ans << endl;
}
