#include <bits/stdc++.h>
using namespace std;
const int M = 2e5 + 5000;
const int mod = 1e9 + 7;
const int inf = 1e9;
map<long long, int> vis;
int main() {
  int n;
  scanf("%d", &n);
  vis[0] = 1;
  long long sum = 0;
  int ans = 0, ch;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &ch);
    sum += 1ll * ch;
    ans += vis[sum];
    vis[sum]++;
  }
  printf("%d", ans);
}
