#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3f3f;
template <typename T, typename U>
inline void amin(T &x, U y) {
  if (y < x) x = y;
}
template <typename T, typename U>
inline void amax(T &x, U y) {
  if (x < y) x = y;
}
template <typename T>
inline void out(T x) {
  cout << x;
}
unordered_map<int, int> H;
long long ans;
int main() {
  int n, m;
  cin >> n >> m;
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    sum = (sum + x) % m;
    H[sum]++;
    if (sum % m == 0) ans++;
  }
  for (auto i : H) ans += i.second * (i.second - 1) / 2;
  cout << ans;
}
