#include <bits/stdc++.h>
using namespace std;
inline long long Pow_mod(long long x, long long pow) {
  if (pow == 0) return 1;
  long long a = Pow_mod(x, pow / 2);
  a = a * a % 1000000007;
  if (pow % 2 == 1) a *= x;
  return a % 1000000007;
}
inline long long factorial_mod(long long x) {
  long long res = 1;
  for (long long i = 1; i <= x; i++) {
    res = (res * i) % 1000000007;
  }
  return res;
}
inline long long nPr_mod(long long n, long long r) {
  long long res = 1;
  for (long long i = n; i > n - r; i--) {
    res = (res * i) % 1000000007;
  }
  return res;
}
inline long long nCr_mod(long long n, long long r) {
  return factorial_mod(n) *
         Pow_mod(factorial_mod(r) * factorial_mod(n - r) % 1000000007,
                 1000000007 - 2) %
         1000000007;
}
signed main() {
  long long n, m;
  cin >> n >> m;
  map<long long, long long> ma;
  ma[0]++;
  long long sum = 0, x;
  for (long long i = 0; i < (n); i++) {
    cin >> x;
    sum += x;
    ma[sum % m]++;
  }
  long long ans = 0;
  map<long long, long long>::iterator it = ma.begin();
  while (it != ma.end()) {
    if ((*it).second != 0 && (*it).second != 1)
      ans = (ans + nCr_mod((*it).second, 2)) % 1000000007;
    it++;
  }
  cout << ans;
}
