#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main() {
  int n;
  long long m;
  cin >> n >> m;
  long long a[n];
  long long b[n + 1];
  b[0] = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i + 1] = (b[i] + a[i]) % m;
  }
  sort(b, b + n + 1, greater<long long>());
  long long ans = 0;
  int tem = 1;
  for (int i = 1; i < n + 1; i++) {
    if (b[i] == b[i - 1]) {
      tem++;
    } else {
      ans += tem * (tem - 1) / 2;
      tem = 1;
    }
  }
  ans += tem * (tem - 1) / 2;
  cout << ans << endl;
}
