#include <bits/stdc++.h>
using namespace std;
const long long POSITIVE_INFINITY = 9223372036854775807;
const long long NEGATIVE_INFINITY = -9223372036854775807;
const long long MOD = 1000000007;
const long double PI = acos(-1.0);
template <typename T>
inline T bigMod(T A, T B, T M = MOD) {
  A %= M;
  T ret = 1;
  while (B) {
    if (B & 1) ret = (ret * A) % M;
    A = (A * A) % M;
    B = B >> 1;
  }
  return ret;
}
template <typename T>
inline T invMod(T A, T M = MOD) {
  return bigMod(A, M - 2, M);
}
const int N = 200005;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  unordered_map<int, int> mp;
  int n, m;
  cin >> n >> m;
  mp[0] = 1;
  long long ans = 0;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    sum += x;
    sum %= m;
    ans += mp[sum];
    mp[sum]++;
  }
  cout << ans << "\n";
  return 0;
}
