#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> S(N);
  for (int i = 0; i < N; i++) {
    cin >> S[i];
    S[i] %= M;
    if (i) S[i] = (S[i] + S[i - 1]) % M;
  }
  sort(S.begin(), S.end());
  long long ima = 0, cnt = 1, ans = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == ima) cnt++;
    if (S[i] != ima) {
      ans += cnt * (cnt - 1) / 2;
      ima = S[i];
      cnt = 1;
    } else if (i == N - 1)
      ans += cnt * (cnt - 1) / 2;
    ans %= 1000000007;
  }
  cout << ans << endl;
}
