#include <bits/stdc++.h>
using namespace std;
long long int MOD = 1000000007;
long long int INFL = 1ll << 60;
long long int INF = 1 << 28;
template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  cout << "{";
  for (int i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  cout << "}";
  return os;
}
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 < n; i++) rui[i + 1] = (rui[i] + v[i]) % m;
  sort(rui.begin(), rui.end());
  cout << rui << endl;
  long long int ans = 0, count = 1;
  for (int i = 0; i <= n; i++) {
    if (i != n && rui[i + 1] == rui[i])
      count++;
    else {
      if (2 <= count) ans = ans % MOD + count * (count - 1) / 2 % MOD;
      count = 1;
    }
  }
  cout << ans << endl;
}
