#include <bits/stdc++.h>
using namespace std;
template <class T>
bool uin(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
const int maxn = 1000001;
int main() {
  int n, m;
  cin >> n >> m;
  map<long long, long long> naksha;
  long long pre[n + 1];
  pre[0] = 0;
  int x;
  for (long long i = (long long)(1); i <= (long long)(n); ++i) {
    cin >> x;
    pre[i] = pre[i - 1] + x;
    pre[i] %= m;
  }
  int ans = 0;
  naksha[0] = 1;
  for (long long i = (long long)(1); i <= (long long)(n); ++i) {
    ans += naksha[pre[i]];
    naksha[pre[i]]++;
  }
  cout << ans;
  return 0;
}
