#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
int main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> A(N);
  for (long long i = 0; i < N; i++) {
    cin >> A[i];
    A[i] %= M;
  }
  for (long long i = 0; i < N; i++) {
    if (i) {
      A[i] += A[i - 1];
      A[i] %= M;
    }
  }
  map<long long, long long> mp;
  mp[0]++;
  for (long long i = 0; i < N; i++) {
    mp[A[i]]++;
  }
  long long res = 0;
  for (auto ne : mp) {
    res += ne.second * (ne.second - 1) / 2;
    res %= MOD;
  }
  cout << res << endl;
  return 0;
}
