#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
using ll = long long;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll m = 1000000007;
int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> mo(N);
  for (ll i = 0LL; i < N; i++) {
    ll x;
    cin >> x;
    if (i == 0LL)
      mo[i] = x % M;
    else
      mo[i] = (mo[i - 1] + x) % M;
  }
  vector<ll> mod(M);
  for (ll i = 0LL; i < N; i++) mod[mo[i]]++;
  ll ans = 0LL;
  for (ll i = 0LL; i < M; i++) {
    if (i == 0LL)
      ans += ((mod[i] + (mod[i] * (mod[i] - 1LL) / 2LL))) % m;
    else
      ans += (mod[i] * (mod[i] - 1LL) / 2LL) % m;
    ans %= m;
  }
  cout << ans << endl;
}
