#include <bits/stdc++.h>
using namespace std;
const long long inf = 1 << 30;
map<long long, int> mp;
map<long long, int>::iterator it;
const int maxn = 1e5;
int vis[2 * maxn + 5];
int main() {
  vis[0] = 0, vis[1] = 0;
  for (int i = 2; i < 2 * maxn + 5; i++) vis[i] = vis[i - 1] + i - 1;
  int n;
  cin >> n;
  long long sum = 0;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    sum += a;
    mp[sum]++;
  }
  for (it = mp.begin(); it != mp.end(); it++) {
    if (it->first == 0) ans += it->second;
    ans += vis[it->second];
  }
  cout << ans << endl;
  return 0;
}
