#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};
int main() {
  ll N, M;
  cin >> N >> M;
  ll info[N];
  ll ans = 0;
  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);
  }
  for (auto p : count) {
    ll now;
    if (p.first)
      now = p.second * (p.second - 1) / 2;
    else
      now = (p.second + 1) * p.second / 2;
    now %= MOD;
    ans = (ans + now) % MOD;
  }
  cout << ans << endl;
  return 0;
}
