#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int mod = 1000000007;
void solve();
int main(void) {
  int N;
  ll M;
  cin >> N >> M;
  ll A[N + 1];
  for (int i = 0; i < N; i++) cin >> A[i + 1];
  A[0] = 0;
  ll ruiseki[N + 1];
  ruiseki[0] = A[0] % M;
  for (int i = 1; i <= N; i++) {
    ruiseki[i] = (ruiseki[i - 1] + A[i]) % M;
  }
  sort(ruiseki, ruiseki + (N + 1));
  ll row = 1;
  ll ans = 0;
  for (int i = 1; i <= N; i++) {
    if (ruiseki[i] == ruiseki[i - 1])
      row++;
    else {
      ans += row * (row - 1) / 2;
      row = 1;
    }
  }
  ans += row * (row - 1) / 2;
  cout << ans % mod << endl;
  return 0;
}
void solve() {}
