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