// Original C++ solution (slower):
/*

                                                     ``.-''!!!!!!!!!!!!!!!!!!!!!!!!!!!''-..`                                                     

                                            `.'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'.`                                            

                                     `.'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'.`                                     

                                `.!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!.`                                

                            `'!!!!!!!!!!!!!!!!!!(((*****((!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'`                            

                        `'!!!!!!!!!!!+"u%$$####################$$%3""!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'`                        

                     .!!!!!!!!!!!!!"#############$$$$$$$$$############$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!.                     

                  `!!!!!!!!!!!!!!!!!"z%%3I"+(!!!!!!!!!!!!!!!!!!*"I3%%j(!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!`                  

                -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!-                

              '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!(*"""""IjjjjIt""""*(!!!!!!!!!!!!!!!!!!!!'              

            '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!(I%$$##$$%"!!!!!!!!!!!!!!!!!!!!!!!!!!!3$##########################$$3""!!!!!!!!!!!!!!'            

          .!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"$############$(!!!!!!!!!!!!!!!!!!!!!!!($######$#########$3&%$$$##########$!!!!!!!!!!!!!!.          

         !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!t################(!!!!!!!!!!!!!!!!!!!!!!!!!!!!!I$###########%(!!!!!!("j%$%3*!!!!!!!!!!!!!!!!         

       `!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!$################"!!!!!!!!!!!!!!!!!!!!!!!!!!!!$###############"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!`       

      .!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!$##############%!!!!!!!!!!!!!!!!!!!!!!!!!!!!"################$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!.      

     `!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"$##########%*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!$###############"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!`     

     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!+""""*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!I$###########%(!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!     

    .!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"j3%%%z"*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!.    

    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    

    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    

    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    

    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!(+"""+*(!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    

    '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!+""""""""""*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'    

     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!""""""""""""*!!!!"$$#################$$$3j"+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!     

     .!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"""""""""""""!!!u############################$$J"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!.     

      '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"""""""""""""(!!!!!((!!!!!!!!!!!!!!(*""u%$########$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'      

       '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!""""""""""""""*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!+t%$%3+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'       

        .!!!!!!!!!!!!!!!!!!!!!!!!!!!!!("""""""""""""""!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!(((*+""""""+(!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!.        

          !!!!!!!!!!!!!!!!!!!!!!!!!(""""""""""""""""+!!!!!!!!!!!!!!!!!!!!(((*+"""""""""""""""""""""""!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!          

           .!!!!!!!!!!!!!!!!!!!(+"""""""""""""""""(!!!!!!!(((*+"""""""""""""""""""""""""""""""""""""(!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!.           

             .!!!!!!!!!!!!!!("""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""+*(((!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!.             

               .!!!!!!!!!!("""""""""""""""""""""""""""""""""""""""""""""""""+*(((!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!.               

                 `'!!!!!!"""""""""""""""""""""""""""""""""""""""""""""""""""(!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'`                 

                    .!!!""""""""""""""""""""""""""""""""""""""""""""""""""""""!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!.                    

                       ."""""""""""""""""""""""""""""""""""""""""""""""""""""!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'`                       

                        !""""""""""""""""""""""""""""""""""""""""""""""""""(!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!.                           

                        .""""""""""""""""""""""""""""""""""""""""""""""""""""!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'.                               

                         .*""""""""""""""""""""""""""""""""""""""""""""""""""!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'.                                    

                           !""""""""""""""""""""""""""""""""""""""""""""""(!!!!!!!!!!!!!!!!!!!!!!!!!'-.                                          

                             !(""""""""""""""""""""""""""""""""""""""""""""!!!!!!!!!!!!!!!!''.``                                                 

                               `!!""""""""""""""""""""""""""""""""""""""""!..`````                                                               

                                   .!!!*"""""""""""""""""""""""""+(!!!!!.                                                                        



        _            _                  _            _       _     _         _   _          _          _             _        

       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      

      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     

     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    

    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    

    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  

     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 

 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 

/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  

\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   

 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    

                                                                                                                              

*/

#include<bits/stdc++.h>

using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()

#define REP(i, n) for(int i = 0;i < (n);++i)



#define endl '\n'

#define pb emplace_back

#define mkp make_pair

#define p_q priority_queue

#define INF 2000000000

#define PI 3.1415926



const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};

const long long MOD = 1e9+7;



// typedef long long ll;

#define int long long



template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}

template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}

template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}

template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}



signed main(void){

  cin.tie(0);

  ios::sync_with_stdio(false);



  int n, a; cin >> n;

  int sum[200010] = {0};

  map<int, int> mp; mp[0]++;

  REP(i, n) {

    cin >> a;

    sum[i+1] = sum[i] + a;

    mp[sum[i+1]]++;

  }

  int ans = 0;

  for(auto itr : mp){

    if(itr.second >= 2) ans += itr.second*(itr.second-1)/2;

  }

  cout << ans << endl;



  return 0;

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

#define ALL(obj) (obj).begin(),(obj).end()

#define RALL(obj) (obj).rbegin(),(obj).rend()

#define REP(i, n) for(int i=0;i<(n);++i)

#define RANGE(i, a, b) for(int i=(a);i<(b);++i)

#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)



#define endl '\n'

#define pb push_back

#define eb emplace_back

#define pque priority_queue

#define umap unordered_map

#define uset unordered_set

#define BIG 2000000000

#define VERYBIG 1000000000000000ll

#define PI 3.141592653589793238

#define dcout cout<<fixed<<setprecision(50)



const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};

const long long MOD = 1e9+7;



// typedef long long ll;

#define int long long

#define double long double



template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}

template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}

template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}

template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}

template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}



typedef pair<int, int> INTP;

typedef vector<int> INTV;

struct edge2 {int to, cost;};

struct edge3 {int from, to, cost;};



signed main(void){

  cin.tie(0);

  ios::sync_with_stdio(false);



  int N, A[200010]; cin >> N;

  map<int, int> mp;

  mp[0]++;

  REP(i, N) cin >> A[i+1], A[i+1] += A[i], mp[A[i+1]]++;

  int ans = 0;

  for(auto itr : mp){

    ans += itr.second * (itr.second-1) / 2;

  }

  cout << ans << endl;

}

// Fastest known solution for this problem: