#include <bits/stdc++.h>
using namespace std;
int n;
map<int, int> a;
unsigned long long ans, cur;
int main() {
  cin >> n;
  a[0]++;
  while (n--) {
    int temp;
    cin >> temp;
    cur += temp;
    cur = cur % 10000007;
    a[cur]++;
  }
  for (auto x : a) {
    unsigned long long temp = x.second;
    ans += temp * (temp - 1) / 2;
    ans = ans % 10000007;
  }
  cout << ans;
  return 0;
}
