#include <bits/stdc++.h>
using namespace std;
const int vx[4] = {0, 1, 0, -1};
const int vy[4] = {1, 0, -1, 0};
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  long long n, m;
  cin >> n >> m;
  map<long long, long long> mp;
  long long ans = 0;
  vector<long long> a(n);
  for (long long i = (long long)0; i < (long long)n; i++) {
    cin >> a[i];
    if (i) {
      a[i] += a[i - 1];
    }
  }
  for (long long i = (long long)0; i < (long long)n; i++) {
    a[i] %= m;
    mp[a[i]]++;
  }
  mp[0]++;
  for (pair<long long, long long> m : mp) {
    ans += (m.second - 1) * m.second / 2;
    ans %= (long long)(1e9 + 7);
  }
  cout << ans << endl;
}
