#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin>>n>>k;
    vector<int> v;
    int br=0, br1=0;
    for(int i=0;i<n;i++){
        int buff;
        cin>>buff;
        if(buff==0) br++;
        else{
            br1+=br*(br-1)/2;
            br=0;
        }
    }
    br1+=br*(br-1)/2;
    cout<<n*(n-1)/2-br1;
    return 0;
}
