#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;
int main() {
source:
  ll n, m;
  cin >> n >> m;
  ll a[n];
  for (ll i = (0); i < (n); i++) {
    cin >> a[i];
  }
  ll sum[n];
  sum[0] = a[0] % m;
  for (ll i = (1); i < (n); i++) {
    sum[i] = sum[i - 1] + a[i];
    sum[i] %= m;
  }
  map<ll, ll> memo;
  memo[0] = 1;
  for (ll i = (0); i < (n); i++) {
    ll x = sum[i];
    if (memo[x] == 0) {
      memo[x] = 1;
    } else {
      memo[x]++;
    }
  }
  ll ans = 0;
  for (auto iter = memo.begin(); iter != memo.end(); iter++) {
    ll num = iter->second;
    if (num >= 2) {
      ans += num * (num - 1) / 2;
    }
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}
