#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, M;
  cin >> N >> M;
  long long b = 0;
  unordered_map<long long, long long> B;
  B[0] = 1;
  for (int i = 0; i < N; ++i) {
    long long tmp;
    cin >> tmp;
    b += tmp;
    B[b % M] += 1;
  }
  long long ans = 0;
  for (auto itr = B.begin(); itr != B.end(); ++itr) {
    ans += itr->second * (itr->second - 1) / 2LL;
    ans %= 1000000007;
  }
  cout << ans << endl;
  return 0;
}
