#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
void solve(long long N, long long M, std::vector<long long> A) {
  vector<long long> sum((N + 1), 0);
  ;
  map<long long, long long> a;
  for (int(i) = 0; (i) < (N); (i)++) {
    sum[i + 1] = sum[i] + A[i];
    a[sum[i] % M]++;
  }
  long long ans = 0;
  for (int(i) = 0; (i) < (N); (i)++) {
    if (sum[i] % M == 0)
      ans += a[sum[i] % M];
    else
      ans += a[sum[i] % M] - 1;
    a[sum[i] % M]--;
    ans %= MOD;
  }
  cout << (ans) << endl;
  ;
}
int main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, M, std::move(A));
  return 0;
}
