#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
 
int main()
{
   map<ll, ll> mp;
   mp[0]++;
   int N;
   cin >> N;
   ll a, sum = 0;
   ll ans = 0;
   for(int i = 0; i < N; i ++)
    {
          cin >> a
         sum += a;
         ans += mp[sum];
        mp[sum] ++;
     }
    cout << ans << endl;
   return 0;
}