#include <bits/stdc++.h>
using namespace std;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  long long N, M, ans = 0, s = 0;
  vector<long long> A, sum;
  map<long long, long long> d;
  cin >> N >> M;
  A.resize(N);
  for (long long i = 0; i < N; i++) {
    cin >> A[i];
    s += A[i];
    d[s % M]++;
  }
  s = 0;
  for (long long i = 0; i < N; i++) {
    long long t = s % M;
    ans += d[t];
    ans %= ((long long)1e9 + 7);
    s += A[i];
    d[s % M]--;
  }
  cout << ans << "\n";
  return 0;
}
