#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 7;
const long long mod = 1e9 + 7;
long long N;
long long A[200000], sum, ans;
map<long long, long long> B;
queue<long long> C;
long long mod_pow(long long x, long long n) {
  if (n == 0) return 1;
  long long res = mod_pow(x * x % mod, n / 2);
  if (n & 1) res = res * x % mod;
  return res;
}
const int MAX_NUM = 200010;
long long fact[MAX_NUM], inv[MAX_NUM];
long long comb(long long n, long long k) {
  if (n < k || n < 0 || k < 0) return 0;
  if (fact[0] == 0) {
    fact[0] = 1;
    inv[0] = 1;
    for (int i = 1; i < MAX_NUM; i++) {
      fact[i] = fact[i - 1] * i % mod;
      inv[i] = mod_pow(fact[i], mod - 2);
    }
  }
  return (((fact[n] * inv[k]) % mod) * inv[n - k]) % mod;
}
int main() {
  cin >> N;
  B[0] = 1;
  for (long long i = 0; i < N; i++) {
    long long unko;
    cin >> unko;
    sum += unko;
    if (B[sum] == 1) {
      C.push(sum);
    }
    B[sum]++;
  }
  while (!C.empty()) {
    long long part = C.front();
    C.pop();
    ans = (ans + comb(B[part], 2)) % mod;
  }
  cout << ans << endl;
  return 0;
}
