#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
namespace atcoder {
void judge_outer(bool judge_exp, string ok = "Yes", string ng = "No") {
  if (judge_exp) {
    cout << ok << endl;
  } else {
    cout << ng << endl;
  }
}
int ncr(int left, int right) {
  right = min(left - right, right);
  int ans = 1;
  for (int i = 1; i <= right; i++) {
    ans = ans * (left - right + i) / i;
  }
  return ans;
}
const int LIMIT = 1000000256;
const int tenfive = 100100;
}  // namespace atcoder
using namespace atcoder;
int main() {
  int N, M;
  cin >> N >> M;
  vector<lli> num(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &num[i]);
    if (i >= 1) {
      num[i] += num[i - 1];
    }
  }
  lli ans = 0;
  for (int i = 0; i < N; i++) {
    num[i] %= M;
  }
  sort(num.begin(), num.end());
  int save = num[0];
  int counter = 1;
  if (num[0] == 0) {
    counter++;
  }
  for (int i = 1; i < N; i++) {
    if (save == num[i]) {
      counter++;
    } else {
      if (counter != 1) {
        ans += ncr(counter, 2);
      }
      save = num[i];
      counter = 1;
    }
  }
  if (counter != 1) {
    ans += ncr(counter, 2);
  }
  cout << ans << endl;
}
