#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;
const ll MAX = 101010;
ll fac[MAX], finv[MAX], inv[MAX];
void combinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
ll comb(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll N, M;
int main() {
  cin >> N >> M;
  vector<ll> sum(N + 1, 0);
  map<ll, ll> mp;
  combinit();
  for (int i = 1; i < N + 1; ++i) {
    cin >> sum[i];
  }
  for (int i = 1; i < N + 1; ++i) {
    sum[i] += sum[i - 1];
  }
  for (int i = 0; i < N + 1; ++i) {
    sum[i] %= M;
  }
  for (int i = 0; i < N + 1; ++i) {
    mp[sum[i]]++;
  }
  ll ans = 0;
  for (auto x : mp) {
    if (x.second >= 2) {
      ans += comb(x.second, 2);
    }
  }
  cout << ans % MOD << endl;
  return 0;
}
