#include <bits/stdc++.h>
using namespace std;
using P = pair<long, long>;
const int mod = 1000000007;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long n, m;
  cin >> n >> m;
  map<long, int> mp;
  vector<long> a(n);
  for (int i = 0; i < (n); i++) scanf("%ld", &a[i]);
  ;
  vector<long> b(n + 1);
  b[0] = 0;
  mp[0]++;
  for (int i = 0; i < (int)(n); i++) {
    b[i + 1] = (b[i] + a[i]) % m;
    mp[b[i + 1]]++;
  }
  long res = 0;
  for (auto x : mp) {
    if (x.second > 1) {
      res += x.second * (x.second - 1) / 2;
    }
  }
  cout << res << endl;
}
