#include <bits/stdc++.h>
using namespace std;
bool prime(long long x) {
  for (long long i = 2; i * i <= x; i++) {
    if (x % i == 0) return false;
  }
  return x > 1;
}
long long gcd(long long x, long long y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
long long lcm(long long x, long long y) { return x / gcd(x, y) * y; }
long long kai(long long x, long long y) {
  long long res = 1;
  for (long long i = x - y + 1; i <= x; i++) {
    res *= i;
    res %= (long long)(1e9 + 7);
  }
  return res;
}
long long mod_pow(long long x, long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) {
      res = res * x % (long long)(1e9 + 7);
    }
    x = x * x % (long long)(1e9 + 7);
    y >>= 1;
  }
  return res;
}
long long comb(long long x, long long y) {
  if (y > x) return 0;
  return kai(x, y) * mod_pow(kai(y, y), (long long)(1e9 + 7) - 2) %
         (long long)(1e9 + 7);
}
long long n, m, sum;
map<long long, long long> mp;
signed main() {
  cin >> n >> m;
  mp[0] = 1;
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    long long a;
    cin >> a;
    sum += a;
    ans += mp[sum % m];
    mp[sum % m]++;
    ans %= (long long)(1e9 + 7);
  }
  cout << ans << endl;
}
