#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
constexpr int MOD = 1000000007;
const int INF = 1 << 30;
lint choose2(lint n) { return n * (n - 1) / 2; }
int main() {
  int n, m;
  cin >> n >> m;
  vec a(n);
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  vector<lint> s(n + 1);
  for (int i = 0; i < (int)(n); i++) s[i + 1] = (s[i] + a[i]) % m;
  map<int, int> mp;
  for (int i = 0; i < (int)(n + 1); i++) mp[s[i]]++;
  lint res = 0;
  for (auto [k, v] : mp) {
    res += choose2(v);
  }
  cout << res << "\n";
  return 0;
}
