#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 17, maxN = 4 * N, darr = 1e3 + 17, mod = 1e9 + 7;
int n;
int a[N];
map<long long, long long> m;
long long p[N];
int main() {
  ios_base::sync_with_stdio;
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    p[i] = p[i - 1] + a[i];
  }
  int res = 0;
  for (int i = 0; i <= n; i++) {
    res += m[p[i]];
    m[p[i]]++;
  }
  cout << res;
  return 0;
}
