#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int n, m;
long long ans;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  vector<long long> a(n);
  map<long long, long long> mem;
  for (int i = 0; i < (n); ++i) cin >> a[i];
  long long sum = 0;
  mem[0] = 1;
  for (int i = 0; i < (n); ++i) {
    sum = sum + a[i - 1];
    mem[sum % m]++;
  }
  for (auto itr = mem.begin(); itr != mem.end(); ++itr) {
    long long p = itr->second;
    ans += p * (p - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
