#include <bits/stdc++.h>
using namespace std;
const long long INFL = 1e18;
const int INF = 1001001001;
const int mod = 1000000007;
const int PI = acos(-1);
int main() {
  int n, m;
  cin >> n >> m;
  int a[n];
  for (int i = 0; i < (n); i++) {
    cin >> a[i];
    a[i] %= m;
  }
  long long sum[n];
  sum[0] = a[0];
  for (int i = 0; i < (n); i++) {
    if (i == 0) continue;
    sum[i] = sum[i - 1] + a[i];
    sum[i] %= m;
  }
  vector<long long> mo(m, 0);
  for (int i = 0; i < (n); i++) {
    mo[sum[i] % m]++;
  }
  long long ans = 0;
  mo[0]++;
  for (int i = 0; i < (m); i++) {
    if (mo[i] == 0) continue;
    ans += (mo[i] * (mo[i] - 1)) / 2;
  }
  cout << ans << endl;
}
