#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pl = pair<ll, ll>;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
const ll MOD = 1000000007;
const ll MOD9 = 998244353;
const int inf = 1e9;
const ll INF = 4e18;
const ll dy[4] = {1, 0, -1, 0};
const ll dx[4] = {0, -1, 0, 1};
const ll MAX = 1100000;
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (ll 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 COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 or k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
  COMinit();
  ll N, M;
  cin >> N >> M;
  ll info[N];
  for (ll i = 0; i < N; i++) cin >> info[i];
  ll sum[N];
  sum[0] = info[0];
  for (ll i = (1); i < (N); i++) sum[i] = sum[i - 1] + info[i];
  map<ll, ll> count;
  for (ll i = 0; i < N; i++) {
    sum[i] %= M;
    if (count.count(sum[i]))
      count[sum[i]]++;
    else
      count.emplace(sum[i], 1);
  }
  ll ans = 0;
  for (auto p : count) {
    ll now = COM(p.second, 2);
    if (p.first == 0) now += p.second;
    ans = (ans + now) % MOD;
  }
  cout << ans << endl;
  return 0;
}
