#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N;
  cin >> N;
  ;
  int M;
  cin >> M;
  ;
  vector<ll> sum(N + 1, 0);
  map<ll, int> m;
  ++m[0];
  for (int i = 0, _i = (N); i < _i; ++i) {
    int a;
    cin >> a;
    ;
    sum[i + 1] = sum[i] + a;
    sum[i + 1] %= M;
    ++m[sum[i + 1]];
  }
  int ans = 0;
  for (int i = 0, _i = (N); i < _i; ++i) {
    --m[sum[i + 1]];
    ans += m[sum[i + 1]];
  }
  cout << ans << endl;
  return 0;
}
