#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;
ll N, M;
int main() {
  cin >> N >> M;
  vector<ll> sum(N + 1, 0);
  map<ll, ll> mp;
  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 = 0LL;
  for (auto x : mp) {
    if (x.second >= 2) {
      ans += ((x.second) * (x.second - 1) / 2) % MOD;
      ans %= MOD;
    }
  }
  cout << ans % MOD << endl;
  return 0;
}
