#include <bits/stdc++.h>
using namespace std;
long long int MOD = 1000000007;
int main() {
  long long int n, m;
  cin >> n >> m;
  vector<long long int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  vector<long long int> rui(n + 1);
  for (int i = 0; i < v.size(); i++) rui[i + 1] = (rui[i] + v[i]) % m;
  map<long long int, int> mp;
  for (int i = 0; i < rui.size(); i++) mp[rui[i]]++;
  long long int ans = 0;
  for (auto x : mp)
    if (2 <= x.second) ans = (ans + x.second * (x.second - 1) / 2 % MOD) % MOD;
  cout << ans << endl;
}
