#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const int MOD = 1e9 + 7;
const long long INF = 1e18;
const double PI = acos(-1);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, -1, 1, 1, -1};
int ddx[5] = {2, 1, 0, -1, -2};
int ddy[5] = {2, 1, 0, -1, -2};
const int MAX = 510000;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (long long i = 0; i < n; ++i) cin >> a[i];
  vector<long long> s(n + 1);
  for (long long i = 0; i < n; ++i) s[i + 1] = s[i] + a[i];
  long long cnt = 0;
  long long ans = 0;
  for (long long i = 0; i < n; ++i) {
    long long x = s[i + 1];
    if (x % m == 0) {
      ans++;
      cnt++;
    }
  }
  ans += cnt * (cnt - 1) / 2;
  cout << ans << '\n';
  return 0;
}
