#include <bits/stdc++.h>
using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> As(N);
  for (auto &Ai : As) cin >> Ai;
  map<int, LLONG> mod2NumMap;
  int mod = As[0] % M;
  ++mod2NumMap[mod];
  for (int i = 1; i < N; ++i) {
    mod = (mod + As[i]) % M;
    ++mod2NumMap[mod];
  }
  LLONG ans = 0LL;
  auto zeroItr = mod2NumMap.find(0);
  if (zeroItr != mod2NumMap.end()) {
    ans = (ans + zeroItr->second) % MOD;
  }
  for (const auto &kvp : mod2NumMap) {
    LLONG num = kvp.second;
    LLONG pairNum = num * (num - 1) / 2LL;
    ans = (ans + pairNum) % MOD;
  }
  cout << ans << endl;
}
