/*raghav0307 - Raghav Gupta*/

#include <bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define pb push_back
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int ll

typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;

signed main(){
	fast_io();
	map<int, int> mp;
  	int s = 0;
  	mp[s]++;
  	int n;
  	cin >> n;
  	for(int i = 0; i < n; i++){
      int x;
      cin >> x;
   	  s += x;
      mp[s]++;
    }
  	int ans = 0;
  	for(auto x : ans){
      ans += (x.ss*(x.ss-1))/2;
    }
  	cout << ans << "\n";
	return 0;
}