#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1},
          Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int n, m;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  map<int, int> modm;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    a = a % m;
    sum += a;
    sum %= m;
    modm[sum]++;
  }
  long long ans = 0;
  for (auto itr = modm.begin(); itr != modm.end(); ++itr) {
    int k = itr->first;
    int v = itr->second;
    if (abs(k - m - k) == 1) continue;
    if (k == 0) {
      ans += modm[0];
      ans += modm[k] * (modm[k] - 1) / 2;
    } else {
      ans += modm[k] * (modm[k] - 1) / 2;
    }
  }
  cout << ans << "\n";
}
