#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
struct io {
  io() {
    ios::sync_with_stdio(false);
    cin.tie(0);
  }
};
const int INF = INT_MAX;
const long long int LLINF = 1LL << 60;
const long long int MOD = 1000000007;
const double EPS = 1e-9;
long long int f[101010], rf[101010];
long long int modinv(long long int a) {
  long long int b = MOD, u = 1, v = 0;
  while (b) {
    long long int t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= MOD;
  if (u < 0) u += MOD;
  return u;
}
bool isinit = false;
void init(void) {
  f[0] = 1;
  rf[0] = modinv(1);
  for (int i = 1; i < 101010; i++) {
    f[i] = (f[i - 1] * i) % MOD;
    rf[i] = modinv(f[i]);
  }
}
long long int nCk(int n, int k) {
  if (!isinit) {
    init();
    isinit = 1;
  }
  long long int nl = f[n];
  long long int nkl = rf[n - k];
  long long int kl = rf[k];
  long long int nkk = (nkl * kl) % MOD;
  return (nl * nkk) % MOD;
}
int main() {
  int n;
  cin >> n;
  vector<long long int> v(n);
  for (int i = 0; i < (n); ++i) cin >> v[i];
  vector<long long int> csum(n + 1, 0);
  for (int i = 0; i < (n); ++i) csum[i + 1] = csum[i] + v[i];
  map<int, int> m;
  for (int i = 0; i < (n + 1); ++i) m[csum[i]]++;
  long long int ans = 0;
  for (auto i = m.begin(); i != m.end(); i++) {
    if (i->second >= 2) ans += nCk(i->second, 2);
  }
  cout << (ans) << '\n';
}
