/*
" وَكَانَ فَضْلُ اللَّهِ عَلَيْكَ عَظِيمًا "
╔░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╗
║ ║
║ ███╗ ███╗ ██████╗ ██╗ ██╗ █████╗ ███╗ ███╗ ███████╗ ██████╗ ║
║ ████╗ ████║██╔═══██╗██║ ██║ ██╔══██╗ ████╗ ████║ ██╔════╝ ██╔══██╗ ║
║ ██╔████╔██║██║ ██║███████║ ███████║ ██╔████╔██║ █████╗ ██║ ██║ ║
║ ██║╚██╔╝██║██║ ██║██╔══██║ ██╔══██║ ██║╚██╔╝██║ ██╔══╝ ██║ ██║ ║
║ ██║ ╚═╝ ██║╚██████╔╝██║ ██║ ██║ ██║ ██║ ╚═╝ ██║ ███████╗ ██████╔╝ ║
║ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝ ╚═════╝ ║
║ ║
║ ██╗ ██╗ ██████╗ ███████╗ ███████╗ █████╗ ███╗ ███╗ ║
║ ██║ ██║ ██╔═══██╗ ██╔════╝ ██╔════╝ ██╔══██╗ ████╗ ████║ ║
║ ███████║ ██║ ██║ ███████╗ ███████╗ ███████║ ██╔████╔██║ ║
║ ██╔══██║ ██║ ██║ ╚════██║ ╚════██║ ██╔══██║ ██║╚██╔╝██║ ║
║ ██║ ██║ ╚██████╔╝ ███████║ ███████║ ██║ ██║ ██║ ╚═╝ ██║ ║
║ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ║
║ ║
╚░░░░░░░░░░░░░░░░░░░░░░░ MOHAMED HOSSAM | SOFTWARE ENGINEER ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╝
*/
#include"bits/stdc++.h"
using namespace std;
#define el '\n'
#define ll long long
#define int long long
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define all(x) (x).begin(), (x).end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
template<class T, class U>
T GCD(T a, U b) { return (!b ? a : GCD(b, a % b)); }
template<class T, class U>
T LCM(T a, U b) { return ((a / GCD(a, b)) * b); }
template<class Ta, class Tb>
bool chmax(Ta &a, Tb b) {
if (a >= b) return false;
a = b;
return true;
}
template<class Ta, class Tb>
bool chmin(Ta &a, Tb b) {
if (a <= b) return false;
a = b;
return true;
}
constexpr ll MAX = 300000, MOD = 998244353, MAXN = 2e5 + 10, inf = 1e18;
using vi = vector<int>;
inline void free_palestine() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("inputs.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
template<typename T>
istream &operator>>(istream &in, vector<T> &v) {
for (auto &x: v) in >> x;
return in;
}
template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
for (const auto &x: v) out << x << ' ';
return out;
}
void solve(int tc) {
int n ,x;cin>>n>>x;
unordered_map<int, int> freq;
int sum=0,ans=0;
freq[0] = 1;
for (int i=0;i<n;i++) {
int a;cin>>a;
sum += a;
sum %= x;
ans += freq[sum];
freq[sum]++;
}
cout<<ans<<el;
}
int32_t main() {
free_palestine();
// freopen("collectingofficer.in", "r", stdin);// freopen("palindrome.out", "w", stdout);
int tc = 1;
//cin >> tc;
for (int i = 1; i <= tc; ++i) {
solve(i);
}
/*
⢸⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⡷⠀⠀
⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠢⣀⠀⠀
⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇ Did you get accepted, son?
⢸⠀⠀⠀⠀ ⠖⠒⠒⠒⢤⠀⠀⠀⠀⠀⡇⠀⠀
⢸⠀⠀⣀⢤⣼⣀⡠⠤⠤⠼⠤⡄⠀⠀⡇⠀
⢸⠀⠀⠑⡤⠤⡒⠒⠒⡊⠙⡏⠀⢀⠀⡇⠀
⢸⠀⠀⠀⠇⠀⣀⣀⣀⣀⢀⠧⠟⠁ ⡇
⢸⠀⠀⠀⠸⣀⠀⠀⠈⢉⠟⠓⠀⠀⠀⢀⡇⠀⠀
⢸⠀⠀⠀⠀⠈⢱⡖⠋⠁⠀⠀⠀⠀⠀⡇⠀⡇
⢸⠀⠀⠀⠀⣠⢺⠧⢄⣀⠀⠀⣀⣀⠀⡇⠀⡇
⢸⠀⠀⠀⣠⠃⢸⠀⠀⠈⠉⡽⠿⠯⡆⡇
⢸⠀⠀⣰⠁⠀⢸⠀⠀⠀⠀⠉⠉⠉⠀⡇⠀⡇
⢸⠀⠀⠣⠀⠀⢸⢄⠀⠀⠀⠀⠀⠀⠀⡇⠀⡇⠀
⢸⠀⠀⠀⠀⠀⢸⠀⢇⠀⠀⠀⠀⠀⠀⡇⠀⡇
⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉
*/
}