jiahuimbzuai/CoQuIR huggingface dataset:
//  [rust]
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
   input! {s:chars};
   for i in 0..s.len()-8 {
       print!("{}", s[i]);
   }
   println!("");
}
//  [rust]
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let s = read_as_string();

    println!("{}", &s[0..s.len()-8]);
}
//  [rust]
use proconio::input;

fn main() {
    input! {
        mut s: String,
    }

    for _ in 0..8 {
        let _ = s.pop();
    }

    println!("{}", s);
}
//  [rust]
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:String,
    }
    let mut a=a.chars().collect_vec();
    for i in 0..8 {
        a.pop();
    }
    let a:String=a.iter().collect();
    println!("{}",a)
}
//  [swift]
let S=readLine()!.characters.map{$0}
print(String(S[0..<S.count-8]))
//  [typescript]
import * as fs from "fs";

var input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
console.log(input[0].substring(0, input[0].length - 8));
//  [typescript]
"use strict";
const Main = (input) =>{
   let xs = input.trim().slice(0,input.lastIndexOf('FESTIVAL'));
   console.log(xs);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));
//  [python]
a,b,c,d,e = map(int,input().split())
ans = (c-a) * 60
ans += d-b
print(ans-e)
//  [python]
h1,m1,h2,m2,k = map(int, input().split())
print((h2*60+m2)-(h1*60+m1)-k)
//  [python]
h1, m1, h2, m2, k = map(int, input().split())

awake = h2 * 60 + m2 - h1 * 60 - m1

print(max(awake - k, 0))
//  [python]
from numba import njit


@njit
def main(h, m, H, M, K):
    return max((H-h)*60+(M-m)-K, 0)


h, m, H, M, K = map(int, input().split())


print(main(h, m, H, M, K))
//  [python]
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    h, m, g, m2, k = LI()
    hm = h * 60 + m
    gm = g * 60 + m2
    print(max(0, gm - hm - k))
    return


#main
if __name__ == '__main__':
    solve()
//  [java]
import java.io.*;
import java.util.*;

public class Main {
    static long mod = (int)Math.pow(10,9)+7;
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int h1 = sc.nextInt()*60;
		int m1 = sc.nextInt();
		int h2 = sc.nextInt()*60;
		int m2 = sc.nextInt();
		int k = sc.nextInt();
		pw.println(Math.max(0,(h2+m2)-(h1+m1)-k));
		pw.close();
	}
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}
//  [java]
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) {
        FastReader fastReader = new FastReader();
        int H1 = fastReader.nextInt();
        int M1 = fastReader.nextInt();
        int H2 = fastReader.nextInt();
        int M2 = fastReader.nextInt();
        int K = fastReader.nextInt();
        int minutes = (H2 * 60 + M2) - (H1 * 60 + M1);
        System.out.println(minutes - K);
    }


}
//  [java]
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int h1 = sc.nextInt();
		int m1 = sc.nextInt();
		int h2 = sc.nextInt();
		int m2 = sc.nextInt();
		int k = sc.nextInt();
		sc.close();

		LocalDateTime date1 = LocalDateTime.of(2020,5,30,h1,m1,00);
		LocalDateTime date2 = LocalDateTime.of(2020,5,30,h2,m2,00);

		LocalDateTime date1_1 = date1.plusMinutes(k);

		DateTimeFormatter dtFormat = DateTimeFormatter.ofPattern("HH:mm");
		String sDate1_1 = date1_1.format(dtFormat);
		String sDate2 = date2.format(dtFormat);

		String[] array1 = sDate1_1.split(":");
		String[] array2 = sDate2.split(":");

		int ans = (Integer.parseInt(array2[0])-Integer.parseInt(array1[0]))*60;
		ans = ans + Integer.parseInt(array2[1])-Integer.parseInt(array1[1]);
		System.out.println(ans);

	}
}
//  [java]
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		int h1 = ni();
		int m1 = ni();
		int h2 = ni();
		int m2 = ni();
		int k = ni();

		out(h2 * 60 + m2 - h1 * 60 - m1 - k);

	}

	public static int count(String search, String text) {
		int nsearch = search.length();
		int ntext = text.length();
		int count = 0;

		for (int i = 0; i <= ntext - nsearch + 1; i++) {
			for (int j = i + nsearch - 1; j < ntext; j++) {
				if (search.equals(text.substring(i, j + 1))) {
					count++;
				}
			}
		}

		return count;
	}

	/*
	 * 以下メソッド集
	 */
	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static double nd() {
		return sc.nextDouble();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void out(Object obj) {
		System.out.println(obj.toString());
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static int max(int a, int b) {
		return Math.max(a, b);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static int min(int a, int b) {
		return Math.min(a, b);
	}

	static long min(long a, long b) {
		return Math.min(a, b);
	}
}

class XY {
	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}
//  [java]
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int h1 = in.nextInt();
        int m1 = in.nextInt();
        int h2 = in.nextInt();
        int m2 = in.nextInt();
        int k = in.nextInt();
        int hm1 = h1*60 + m1;
        int hm2 = h2*60 + m2;
        int ans = Math.max(0, hm2 - hm1 - k);
        System.out.println(ans);
    }
}
//  [cpp]
#include <cstdio>

using namespace std;

int main() {
    int h1, m1, h2, m2, k;
    
    scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);
    
    printf("%d\n", h2 * 60 + m2 - h1 * 60 - m1 - k);
    
    return 0;
}
//  [cpp]
#include<cstdio>
int main(){
	int h1,m1,h2,m2,k;
	scanf("%d%d%d%d%d",&h1,&m1,&h2,&m2,&k);
	printf("%d\n",h2*60+m2-h1*60-m1-k);
	return 0;
}
//  [cpp]
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int a,b,c,d,x;
int main()
{
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&x);
	printf("%d\n",max(0,c*60+d-a*60-b-x));
	return 0;
}
//  [c]
#include <stdio.h>

int main() {
    int H1, H2, M1, M2, K, minute_sum = 0;
    scanf("%d %d %d %d %d", &H1, &M1, &H2, &M2, &K);

    minute_sum += (H2 * 60 + M2) - (H1 * 60 +M1);
    printf("%d", minute_sum - K);

    return 0;
}
//  [c]
#include <stdio.h>

int main (void) {
    int h1, m1, h2, m2, k, de;
    scanf("%d%d%d%d%d", &h1, &m1, &h2, &m2, &k);
    m1 += h1*60;
    m2 += h2*60;
    de = m2 - m1;
    printf("%d\n", de-k);
    return 0;
}
//  [c]
#include <stdio.h>
int main()
{
  int a,b,c,d,e,x;
  scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
  x=(c*60+d)-(a*60+b)-e;
  printf("%d\n",x);
  return 0;
}
//  [c]
#include <stdio.h>

int main() {
    int Z1, Z2, X1, X2, Z, Zx, Xy, Yz;
    scanf("%d %d %d %d %d", &Z1, &X1, &Z2, &X2, &Z);
    Zx = Z1 * 60 + X1;
    Xy = Z2 * 60 + X2;
    Yz = Xy - Zx - Z;
    printf("%d", Yz);
    return 0;
}
//  [c]
#include <stdio.h>
int main(void){
    int h,m,hh,mm,k;
    scanf("%d%d%d%d%d",&h,&m,&hh,&mm,&k);
    h=h*60;
    h+=m;
    hh=hh*60;
    hh+=mm;
    h=hh-h;
    h-=k;
    printf("%d\n",h);
    return 0;
    
}
//  [c]
#include<stdio.h>

int main(){
        int fh, fm, lh, lm, k;

        scanf("%d %d %d %d %d", &fh, &fm, &lh, &lm, &k);

        int minute;

        minute=(lh*60+lm)-(fh*60+fm)-k;

        printf("%d", minute);

        return 0;
}
//  [javascript]
function main(input) {
    // 入力値の分離
    param = input.split(" ");
    var hour = param[2] - param[0];
    var min = param[3] - param[1];
    if(min < 0 ){
      hour -= 1;
      min = min * (-1);
      min = 60 - min;
    }
    const limit = (hour * 60) + min
    var result = limit - param[4];
    console.log(result);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function Main(input) {
  var inputs = input.split(" ");
  var h1 = parseInt(inputs[0], 10);
  var m1 = parseInt(inputs[1], 10);
  var h2 = parseInt(inputs[2], 10);
  var m2 = parseInt(inputs[3], 10);
  var k = parseInt(inputs[4], 10);
  
  var minute1 = h1 * 60 + m1;
  var minute2 = h2 * 60 + m2;
  
  var difference = minute2 - minute1;
  console.log(difference - k);
}  
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	const inputLines = input.split("\n");
	const line0 = inputLines[0];
	const line0vars = line0.split(" ");

	const h1 = parseInt(line0vars[0], 10)
	const m1 = parseInt(line0vars[1], 10)
	const h2 = parseInt(line0vars[2], 10)
	const m2 = parseInt(line0vars[3], 10)
	const k = parseInt(line0vars[4], 10)

	// console.log({
	// 	h1: h1,
	// 	m1: m1,
	// 	h2: h2,
	// 	m2: m2,
	// 	k: k
	// });

	const result = h2 * 60 + m2 - h1 * 60 - m1 - k;
	console.log(result);

	// tmp = input[1].split(" ");
	// //文字列から10進数に変換するときはparseIntを使います
	// var a = parseInt(input[0], 10);
	// var b = parseInt(tmp[0], 10);
	// var c = parseInt(tmp[1], 10);
	// var s = input[2];

	//出力
	// console.log('%d %s',a+b+c,s);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

// node index.js
// 1
// 2 3
// test
// (Ctrl + D)
//  [javascript]
const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

totalMins = 0;
let stratFrom = 0;

rl.on('line', function(data){
    data = data.split(' ');
    //console.log(data);

    let from = parseInt(data[0]) * 60 + parseInt(data[1]);
    let to = parseInt(data[2]) * 60 + parseInt(data[3]);
    totalMins = to - from;
    //console.log(totalMins);

    stratFrom = totalMins - parseInt(data[4]);
    //console.log(stratFrom);
    rl.close();
});

rl.on('close', function(){
    console.log(`${stratFrom}`);
})
//  [javascript]
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var one = nextIntArray();
	var H1 = one[0];
	var M1 = one[1];
	var maeTime = H1 * 60 + M1;
	var H2 = one[2];
	var M2 = one[3];
	var atoTime = H2 * 60 + M2;
	var K = one[4];
	var diff = atoTime - maeTime - K;
	myout(diff);
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	H1, M1, H2, M2, K := nextInt(), nextInt(), nextInt(), nextInt(), nextInt()
	H := H2 - H1
	M := abs(M2 - M1)
	if M1 > M2 {
		H--
		M = 60 - M
	}
	fmt.Println(H*60 + M - K)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}
//  [go]
package main

import "fmt"

func main() {
	var h1, h2, m1, m2, k int
	fmt.Scan(&h1, &m1, &h2, &m2, &k)
	begin := h1*60 + m1
	end := h2*60 + m2
	fmt.Println(end - begin - k)
}
//  [go]
package main

import (
  "fmt"
  "time"
)

func main() {
  var a,b,c,d,k int
  loc, _ := time.LoadLocation("Asia/Tokyo")

  fmt.Scanf("%d%d%d%d%d", &a,&b,&c,&d,&k)
  
t1 := time.Date(2020, 1, 1, a, b, 0, 0, loc)
t2 := time.Date(2020, 1, 1, c, d, 0, 0, loc)
  t3:= t2.Add(time.Duration(-k) * time.Minute)
  t4:= t3.Sub(t1)
	fmt.Println(t4.Minutes())
}
//  [go]
package main

import "fmt"

func main() {
	// Code for A - Study Scheduling
	var H1, M1, H2, M2, K int
	fmt.Scanf("%d %d %d %d %d", &H1, &M1, &H2, &M2, &K)

	before := 60*H1 + M1
	after := 60*H2 + M2

	fmt.Println(after - before - K)
}
//  [go]
package main

import (
  "fmt"
)

func main() {
  var h1, h2, m1, m2, k int
  fmt.Scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k)
  
  awake := (h2-h1)*60 + (m2-m1)
  ans := awake - k
  if ans < 0 {
    ans = 0
  }
  fmt.Printf("%d\n", ans)
}
//  [ruby]
h1,h2,m1,m2,k = gets.chomp.split.map(&:to_i)

ji = m1 - h1
fun = m2 - h2

puts (ji*60 + fun) - k
//  [ruby]
h1, m1, h2, m2, k = gets.split.map(&:to_i)

puts h2 * 60 + m2 - k - (h1 * 60 + m1)
//  [ruby]
### SNIPPET
  # n = gets.split.map(&:to_i)
  # array = n.times.map { gets.split.map(&:to_i) }
  # [].all?(&:even?)
  # a = [*1..m].repeated_combination(n).to_a
  # [1,2,3,4,5].select { |num| num.even? }  # => [2, 4]
  # ["a","a","b"].group_by(&:itself).map{|k,v| [k, v.count]}.to_h #=> {"a"=>2, "b"=>1}
  # 切り捨て: .floor(2).to_f ,切り上げ： .ceil(2).to_f,四捨五入: round(2)
  # 3.upto(6) do |i|, 6.downto(3) do |i|
  # 公約数125.gcd(100)、公倍数125.lcm(100)
  # PI = Math::PI
  # 高さ = a * Math.sin(w / 180.0 * Math::PI), 底辺 = a * Math.cos(w / 180.0 * Math::PI)
  # def chmax(a, b) a > b ? a : b end
  # INF = Float::INFINITY
  # def chmin(a, b) a < b ? a : b end

h1,m1,h2,m2,k = gets.split.map(&:to_i)
if m2 - m1 < 0
  min = 60 - m1 + m2
  hour = (h2-1 - h1)*60
else
  min = m2 - m1
  hour = (h2 - h1)*60
end
time = hour + min

yo = time - k

if yo < 0
  puts 0
else
  puts yo
end
//  [ruby]
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
h1,m1,h2,m2,k = gets.chomp.split.map(&:to_i)

puts (h2-h1)*60 + m2 - m1 - k
//  [ruby]
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end
  
a = inp
t = 0
t += (a[2] - a[0])*60
t += (a[3] - a[1])
p t - a[4]
//  [ruby]
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}


# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end
h1, m1, h2, m2, k = gets_i_list

if m2 >= m1
  total = (h2 - h1) * 60 + (m2 - m1)
else
  total = (h2 - h1 - 1) * 60 + (60 + m2 - m1)
end

puts total - k
//  [rust]
#![allow(unused_imports)]
#![allow(unused_variables)]
use proconio::input;
use proconio::marker::*;
use std::cmp::{min, max};
use std::collections::{HashSet, HashMap, BinaryHeap};

fn main() {
    input! {
        h1: isize,
        m1: isize,
        h2: isize,
        m2: isize,
        k: isize,
    }
    let ans = (h2 - h1) * 60 + (m2 - m1) - k;
    println!("{}", max(ans, 0));
}
//  [rust]
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        h1: i64, m1: i64, h2: i64, m2: i64, k: i64,
    }
    puts!("{}\n", 60 * (h2 - h1) + m2 - m1 - k);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}
//  [rust]
fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
    let s = read1::<String>();
    s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T>>()
}

fn main() {
    let hmhmk = readn::<usize>(" ");
    let h1 = hmhmk[0];
    let m1 = hmhmk[1];
    let h2 = hmhmk[2];
    let m2 = hmhmk[3];
    let k = hmhmk[4];

    let t1 = h1 * 60 + m1;
    let t2 = h2 * 60 + m2;
    let dt = t2 - t1;
    println!("{}", dt - k);
}
//  [swift]
let a = readLine()!.split(separator: " ").map({Int($0)!})
let H1 = a[0]
let M1 = a[1]
let H2 = a[2]
let M2 = a[3]
let K = a[4]

if M1 <= M2 {
let time = (H2 - H1) * 60 + M2 - M1
    if time-K>=0 {
        print(time-K)
    } else {
        print(0)
    }
} else {
    let time = (H2 - H1 - 1) * 60 + (60 - M1) + M2
    if time-K>=0 {
        print(time-K)
    } else {
        print(0)
    }
}
//  [swift]
let inputs = readLine()!.split(separator: " ")
let h1 = Int(inputs[0])!
let m1 = Int(inputs[1])!
let h2 = Int(inputs[2])!
let m2 = Int(inputs[3])!
let k = Int(inputs[4])!

let minutes1 = h1 * 60 + m1
let minutes2 = h2 * 60 + m2 - k

let diff = minutes2 - minutes1

print(diff)
//  [swift]
import Foundation

var line = readLine()!.components(separatedBy: " ").map { Int($0)! }
let H1 = line[0]
let M1 = line[1]
let H2 = line[2]
let M2 = line[3]
let K = line[4]

print((H2 - H1) * 60 + (M2 - M1) - K)
//  [swift]
import Foundation

let line: [Int] = readLine()!.components(separatedBy: " ").map { Int($0)! }
let H1 = line[0]
let M1 = line[1]
let H2 = line[2]
let M2 = line[3]
let K = line[4]

print((H2 - H1) * 60 + (M2 - M1) - K)
//  [swift]
import Foundation

var line = readLine()!.components(separatedBy: " ")
let H1 = Int(line[0])!
let M1 = Int(line[1])!
let H2 = Int(line[2])!
let M2 = Int(line[3])!
let K = Int(line[4])!

print((H2 - H1) * 60 + (M2 - M1) - K)
//  [typescript]
import { isRegExp } from "util";

class AtCoder {
  // 入力系
  input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);
  input_i=-1;

  n(){
    this.input_i++;
    return Number(this.input[this.input_i]);
  }
  nn(n:number):number[]{
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.n());
    }
    return a;
  }
  s(){
    this.input_i++;
    return String(this.input[this.input_i]);
  }
  ss(n:number):string[]{
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.s());
    }
    return a;
  }

  // コンソール
  o(...a:any){
    console.log(...a);
  }

  // Math
  abs(a:number){
    return Math.abs(a);
  }
  min(...a:number[]){
    return Math.min(...a);
  }
  max(...a:number[]){
    return Math.max(...a);
  }
  floor(a:number){
    return Math.floor(a);
  }
  ceil(a:number){
    return Math.ceil(a);
  }
  round(a:number){
    return Math.round(a);
  }

  // ソート
  asc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return a-b});
  }
  desc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return b-a});
  }

  // 自作
  gcd(...arr:number[]):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=x;
    }
    return arr[arr.length-1];
  };
  lcm(...arr:number[]):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=arr[i]*arr[i+1]/x;
    }
    return arr[arr.length-1];
  };
  isPrime(n:number):boolean{
    if(n < 2) return false;
    const suq=Math.sqrt(n);
    for(let i=2;i<=suq;i++){
      if(n%i==0){
        return false;
      }
    }return true;
  };
  deduplicate(a:any[]):any[]{
    return Array.from(new Set(a));
  };
  f(roop:number, callback:any){
    for(let i=0;i<roop;i++){
      callback(i);
    }
  };
  Yes(){
    console.log('Yes');
  }
  No(){
    console.log('No');
  }
  YES(){
    console.log('YES');
  }
  NO(){
    console.log('NO');
  }
}
const m = () => {
  const o = new AtCoder();
  let [a,b,c,d,e]=o.nn(5)
  o.o(((c-a)*60+d-b)-e)
}
m();
//  [typescript]
import * as fs from 'fs';

const readString = (() => {
  const input = fs.readFileSync(0).toString();
  const words = input.split(/[ \n]/);
  let i = 0;
  return () => words[i++] || '';
})();
const readInt = () => parseInt(readString(), 10);
const readBigInt = () => BigInt(readString());

const gcd = (a: bigint, b: bigint) => {
  const _gcd = (a: bigint, b: bigint): bigint => {
    const q = a % b;
    return q === 0n ? b : _gcd(b, q);
  };
  return a > b ? _gcd(a, b) : _gcd(b, a);
};

const MOD = 1000000007;
const MOD_BIGINT = BigInt(MOD);
class ModBigInt {
  constructor(public v: bigint) {}

  static of(n: number | bigint) {
    return new ModBigInt(ModBigInt.toBigInt(n));
  }

  static toBigInt(other: number | bigint | ModBigInt) {
    if (typeof other === 'bigint') return other;
    if (typeof other === 'number') return BigInt(other);
    return other.v;
  }

  clone = () => new ModBigInt(this.v);
  plus = (other: number | bigint | ModBigInt) => {
    this.v = (this.v + ModBigInt.toBigInt(other)) % MOD_BIGINT;
    return this;
  };
  minus = (other: number | bigint | ModBigInt) => {
    this.v = (this.v + MOD_BIGINT - ModBigInt.toBigInt(other)) % MOD_BIGINT;
    return this;
  };
  multiply = (other: number | bigint | ModBigInt) => {
    this.v = (this.v * ModBigInt.toBigInt(other)) % MOD_BIGINT;
    return this;
  };
  pow = (other: number) => {
    const v = mod(1);
    for (let i = 0; i < other; i++) v.multiply(this.v);
    return v;
  };
}

const mod = ModBigInt.of;

const abs = (a: bigint) => (a > 0n ? a : -a);

(function main() {
  const H1 = readInt();
  const M1 = readInt();
  const H2 = readInt();
  const M2 = readInt();
  const K = readInt();
  console.log((H2 - H1) * 60 + (M2 - M1) - K);
})();
//  [python]
import sys
input = sys.stdin.readline
from itertools import accumulate
from collections import Counter

N = int(input())
A = map(int, input().split())

def main():
    cumsum = accumulate(A)
    counter = Counter(cumsum)
    yield counter[0]
    for v in counter.values():
        if v > 1:
            yield v*(v-1)//2


print(sum(main()))
//  [python]
import sys
from itertools import accumulate
from collections import Counter

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(map(int, input().split()))

    R = [0] + list(accumulate(A))
    D = Counter(R)

    res = 0
    for v in D.values():
        if v >= 2:
            res += v * (v - 1) // 2
    print(res)


if __name__ == '__main__':
    resolve()
//  [python]
import sys
input = sys.stdin.readline
from itertools import accumulate
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

def main():
    cumsum = accumulate(A)
    counter = Counter(cumsum)
    yield counter[0]
    for v in counter.values():
        if v > 1:
            yield v*(v-1)//2


print(sum(main()))
//  [python]
#!/usr/bin/env python
# -*- coding: utf-8 -*-

IN = 'sample-1.in'  # sample case for local test
def local_test():
    try:
        from pcm.utils import set_stdin
        import sys
        import os
        if len(sys.argv) == 1:
            set_stdin(os.path.dirname(__file__) + '/test/' + IN)
    except:
        pass


import sys
import os
import time
import re
from pydoc import help
import string
import math
import numpy as np
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]


def solve():
    N = int(input())
    A = list(map(int, input().split()))

    CS = [0]*(N+1)

    for n in range(N):
        if n >= 1:
            CS[n+1] = CS[n] + A[n]
        else:
            CS[n+1] = A[n]

    res = 0
    for v in Counter(CS).values():
        if v >= 2:
            res += v*(v-1)//2

    print(res)

if __name__ == "__main__":
    local_test()
    solve()
//  [python]
import numpy as np
from collections import Counter
def f(lst):
    return np.cumsum([0] + lst)

n = int(input())
lst = list(map(int,input().split()))
d = dict(Counter(f(lst)))

res = 0
for k,v in d.items():
    if v >= 2:
        res += (v*(v-1))//2
print(res)
//  [python]
from numpy import cumsum
from collections import Counter
import math
def count(n,r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n = int(input())
a = list(map(int,input().split()))
wa = list(cumsum(a))
wa.append(0)
c = Counter(wa)
keys = set(wa)
ans = 0
for i in keys:
    num = c[i]
    if num >= 2:
        ans += count(num,2)
    else:
        pass
print(ans)
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws IOException{
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		
		String[] tmpArray = br.readLine().split(" ");
		int input[] = new int[n];
		
		int negative = 0;
		int positive = 0;
		
		for(int i = 0; i < n; i++){
			input[i] = Integer.parseInt(tmpArray[i]);
			if(input[i] > 0){
				positive++;
			}
			else if(input[i] < 0){
				negative++;
			}
		}
		
		if((positive > 0 && negative == 0) || (positive == 0 && negative > 0)){
			System.out.println("0");
			return;
		}
		else if(positive == 0 && negative == 0){
			System.out.println((long)n*(n+1)/2);
			return;
		}
		
		long result = 0;
		
//		for(int i = 0; i < n; i++){
//			long tmp = 0;
//			for(int j = i; j < n; j++){
//				tmp += input[j];
//				
////				System.out.print(tmp +" ");
//				if(tmp == 0){
//					result++;
//				}
//			}
//		}
		
//		System.out.println(result);
		System.out.println(solve(input, 0, n));
	}
	
	static long solve(int[] input, int left, int right){
//		System.out.println("left "+left+" right "+right);
		if(right - left <= 1){
			if(input[left] == 0){
				return 1;
			}
			else {
				return 0;
			}
		}
		
		int mid = (left+right)/2;
		
		long result = 0;
		
//		System.out.println("left "+left+" right "+right+ " mid "+mid);
		
		result += solve(input, left, mid);
		result += solve(input, mid, right);
		
//		long rightSum = 0;
		long[] rightSum = new long[right - mid];
		long[] leftSum = new long[mid - left];
		
		long tmpSum = 0;
		for(int i = mid; i < right ; i++){
			tmpSum += input[i];
			
			rightSum[i - mid] = tmpSum;
		}

		tmpSum = 0;
		for(int i = mid - 1; i >= left ; i--){
			tmpSum += input[i];
			
			leftSum[mid - 1 - i] = tmpSum;
		}
		
//		Arrays.sort(leftSum);
		//debug
//		for(int i = 0; i < leftSum.length ; i++){
////			System.out.print(leftSum[i]);
//		}
//		System.out.println();
		Arrays.sort(rightSum);
		
		for(int i = 0; i < leftSum.length ; i++){
			int index = Arrays.binarySearch(rightSum, -leftSum[i]);
			
			if(index >= 0){
				result++;
//				System.out.println("left "+left+" right "+right+" mid "+mid+ "hit "+leftSum[i]);
				
				for(int j = index - 1; j >= 0; j--){
					if(rightSum[j] != -leftSum[i]){
						break;
					}
					result++;
				}
				
				for(int j = index + 1; j < rightSum.length; j++){
					if(rightSum[j] != -leftSum[i]){
						break;
					}
					result++;
				}
			}
		}
		
		
		return result;
	}

}
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;

public class Main
{
  static long t[];
  static long l[];
  static long h[];

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);

    String s;
    String sl[];

    s = r.readLine();
    int n = Integer.parseInt(s);

    HashMap<Long, Long> m = new HashMap<>();
    m.put(0L, 1L);

    long a = 0;
    long v = 0;
    s = r.readLine();
    sl = s.split(" ");
    for(int i = 0; i < n; i++)
    {
      v += Long.parseLong(sl[i]);
      Long z = m.get(v);
      if(z != null && z > 0)
      {
        a += z;
      }
      z = m.getOrDefault(v, 0L);
      m.put(v, z + 1);
    }

    System.out.println(a);
  }

}
//  [java]
import java.util.*;
import java.util.stream.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        long a[]=new long[scanner.nextInt()+1];
        System.out.println(IntStream.range(0,a.length).mapToLong(i->a[i]=(i==0?0:a[i-1]+scanner.nextInt())).boxed().collect(Collectors.groupingBy(i->i,Collectors.counting())).values().stream().mapToLong(i->i*(i-1)/2).sum());
    }
}
//  [cpp]
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	int pn = 1;
	if (*ci == '-') {
		pn = -pn;
		ci++;
	}
	ll tmp = *(ll*)ci;
	int dig = ((tmp & ma0) ^ ma0) ? 68 - __builtin_ctzll((tmp & ma0) ^ ma0) : 0;
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (64 - dig >> 3);
	while ((ct = *ci++) >= '0') tmp = tmp * 10 + ct - '0';
	return pn * tmp;
}

ll A[200001];
void pakuri_sort(int N, ll A[]) {
	const int b = 8;
	ll tmp[200001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint();
	rep1(i, N) {
		A[i] = getint() + A[i - 1];
	}

	pakuri_sort(N + 1, A);

	ll kotae = 0;
	ll mae = 1e18;
	int kazu = 0;
	rep(i, N + 1) {
		if (mae != A[i]) {
			mae = A[i];
			kazu = 0;
		}
		kotae += kazu++;
	}

	printf("%lld\n", kotae);

	Would you please return 0;
}
//  [cpp]
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	int pn = 1;
	if (*ci == '-') {
		pn = -pn;
		ci++;
	}
	ll tmp = *(ll*)ci;
	int dig = ((tmp & ma0) ^ ma0) ? 68 - __builtin_ctzll((tmp & ma0) ^ ma0) : 0;
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (64 - dig >> 3);
	while ((ct = *ci++) >= '0') tmp = tmp * 10 + ct - '0';
	return pn * tmp;
}

ll A[200001];
void pakuri_sort(int N, ll A[]) {
	const int b = 8;
	ll tmp[200001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint();
	rep1(i, N) {
		A[i] = getint() + A[i - 1];
	}

	pakuri_sort(N + 1, A);

	ll kotae = 0;
	ll mae = 1e18;
	int kazu = 0;
	rep(i, N + 1) {
		if (mae != A[i]) {
			mae = A[i];
			kazu = 0;
		}
		kotae += kazu++;
	}

	printf("%lld\n", kotae);

	Would you please return 0;
}
//  [cpp]
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	int pn = 1;
	if (*ci == '-') {
		pn = -1;
		ci++;
	}
	ll tmp = *(ll*)ci;
	int dig = ((tmp & ma0) ^ ma0) ? 68 - __builtin_ctzll((tmp & ma0) ^ ma0) : 0;
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (64 - dig >> 3);
	while ((ct = *ci++) >= '0') tmp = tmp * 10 + ct - '0';
	return pn * tmp;
}

void pakuri_sort(int N, ll A[]) {
	const int b = 8;
	ll tmp[200001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint();
	ll A[200001];
	A[0] = 0;
	rep1(i, N) {
		A[i] = getint() + A[i - 1];
	}

	pakuri_sort(N + 1, A);

	ll kotae = 0;
	int kazu = 1;
	rep(i, N) {
		if (A[i + 1] != A[i]) kazu = 1;
		else kotae += kazu++;
	}

	printf("%lld\n", kotae);

	Would you please return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int N;
    cin >> N;
    vector<lint> A(N, 0);
    rep(i, N) cin >> A[i];

    vector<lint> L(N + 1, 0);
    rep(i, N) L[i + 1] = L[i] + A[i];

    // dump(A);
    // dump(L);

    map<lint, lint> mp;
    for (int i = 0; i <= N; i++) {
        mp[L[i]]++;
    }

    lint cnt = 0;
    for (auto p : mp) {
        lint x, c;
        tie(x, c) = p;
        dd(x, c);
        cnt += c * (c - 1) / 2;
    }

    cout << cnt << endl;
    return 0;
}