#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;
int main() {
  int n, m;
  cin >> n >> m;
  vector<ll> a(n + 1);
  a[0] = 0;
  for (int i = 0; i < n; ++i) {
    int t;
    cin >> t;
    a[i + 1] = a[i] + t;
  }
  unordered_map<int, int> mp;
  for (int i = 0; i < n + 1; ++i) {
    mp[a[i] % m]++;
  }
  ll sum = 0;
  for (auto& e : mp) {
    if (e.second > 1) {
      sum += e.second * (e.second - 1) / 2;
    }
  }
  cout << sum << endl;
  return 0;
}
