#include <bits/stdc++.h>
using namespace std;
template <typename T>
struct cumulative_sum {
  vector<T> data;
  vector<long long int> sum;
  cumulative_sum(const int n) { data.assign(n, 0); }
  T& operator[](const int k) { return data[k]; }
  void build() {
    sum.assign(data.size() + 1, 0);
    for (int i = 0; i < (int)data.size(); i++) {
      sum[i + 1] = sum[i] + data[i];
    }
  }
  long long int query(int a, int b) { return sum[b] - sum[a]; }
};
int main() {
  int n, m;
  cin >> n >> m;
  cumulative_sum<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  a.build();
  unordered_map<long long int, int> count;
  for (int i = 0; i < n + 1; i++) {
    count[(a.sum[i]) % m]++;
  }
  long long int ans = 0;
  for (auto itr = count.begin(); itr != count.end(); itr++) {
    int temp = (*itr).second;
    ans += temp * (temp - 1) / 2;
  }
  cout << ans << endl;
}
