#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;
const double pi = 3.141592653589793;
int main() {
  ll n, m;
  cin >> n >> m;
  ll a[n];
  for (int i = 0; i < (int)(n); i++) {
    cin >> a[i];
  }
  vll s(n + 1);
  int now = 0;
  s.push_back(0);
  for (int i = 0; i < (int)(n); i++) {
    now += a[i];
    now %= m;
    s.push_back(now);
  }
  sort(s.begin(), s.end());
  ll ans = 0;
  now = s[0];
  ll count = 1;
  for (int i = 1; i < n + 1; i++) {
    if (now != s[i]) {
      now = s[i];
      ans += (count) * (count - 1) / 2;
      count = 1;
    } else {
      count += 1;
    }
  }
  ans += (count) * (count - 1) / 2;
  ans %= m;
  cout << ans << endl;
  return 0;
}
