#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
int main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> a(n);
  map<long long, long long> rem;
  rem[0] = 1;
  long long sum = 0, ans = 0;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    sum = sum + a[i];
    rem[sum % m]++;
    ans += rem[sum % m] - 1;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}
