#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const long long LLINF = 1e18;
const long long MOD = 1e9 + 7;
const double EPS = 1e-10;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const int MAX = 100010;
int n;
long long m, a[MAX], b[MAX];
map<long long, long long> mp;
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) b[i + 1] = b[i] + a[i];
  for (int i = 0; i < n + 1; i++) mp[b[i] % m]++;
  long long ans = 0;
  for (auto& x : mp) {
    int num = x.second;
    if (num <= 1) continue;
    ans += num * (num - 1) / 2ll;
  }
  cout << ans << endl;
}
