Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

def clear_maze(sx, sy, gx, gy, maze):
    INF = 10000
    distance = [[INF for i in range(W)] for j in range(H)]
    def bfs():
        queue = []
        queue.insert(0, (sx, sy))
        distance[sy][sx] = 0
        while len(queue):
            x, y = queue.pop()
            if x == gx and y == gy:
                break
            for i in range(0, 4):
                nx, ny = x + [1, 0, -1, 0][i], y + [0, 1, 0, -1][i]
                if (0 <= nx and nx < W and 0 <= ny and ny < H and maze[ny][nx] != '#' and distance[ny][nx] == INF):
                    queue.insert(0, (nx, ny))
                    distance[ny][nx] = distance[y][x] + 1
        return distance[gy][gx]
    return bfs()

H,W = (int(x) for x in input().split())
maze = ['']*H
max_distance = 0
for i in range(H):
  maze[i] = list(input())
  
dic = {}
for i in range(H*W):
  dic[i] = [i % W,i//W,0]
  
for i in range(H*W):
  sx,sy = dic[i][0],dic[i][1]
  s = maze[sy][sx]
  if s == '#':
    continue
  for j in range(H*W):
    gx,gy = dic[j][0],dic[j][1]
    g = maze[gy][gx]
    if i == j or g == '#' or dic[j][2] == 1:
        continue
    tmp_s = s
    tmp_g = g
    maze[sy][sx] = 'S'
    maze[gy][gx] = 'G'
    max_distance = max(max_distance,clear_maze(sx, sy, gx, gy, maze))
    maze[sy][sx] = tmp_s
    maze[gy][gx] = tmp_g
  dic[i][2] = 1
        
print(max_distance)    

    

### FIXED CODE ###

from collections import deque
import math
import copy
H,W = map(int,input().split())
maze = [list(input()) for _ in range(H)]
def bfs(maze,h,w,sx,sy):
    for y in range(h):
        for x in range(w):
            if maze[y][x]=='.':
                maze[y][x]=float('inf')

    maze[sy][sx]=0
    que=deque([[sy,sx]])
    while que:
        y,x=que.popleft()
        for i,j in [(1,0),(0,1),(-1,0),(0,-1)]:
            if 0 <= y+i < H and 0<=x+j<W:
                nexty,nextx=y+i,x+j
                dist=maze[nexty][nextx]
                if dist!='#':
                    if dist>maze[y][x]+1:
                        maze[nexty][nextx]=maze[y][x]+1
                        que.append([nexty,nextx])
    m = 0                   
    for l in maze:
      li = [i for i in l if i != '#' and i < 1000000]
      if len(li) > 0:
        m = max(m,max(li))
    return m
max_dist = -1  
for si in range(H):
  for sj in range(W):
    if maze[si][sj] == '#':
      continue
    copymaze = copy.deepcopy(maze)
    res = bfs(copymaze,H,W,sj,si)
    max_dist = max(max_dist,res)
print(max_dist)
### BUGGY CODE ###

n, k, q = map(int, input().split())

a = [-1] * q
for i in range(q):
    a[i] = int(input())

t = [0] * (n+1)
for i in range(q):
    t[ a[i] ] += 1

p = [k] * (n+1)
for i in range(1, n+1):
    for j in range(1, n+1):
        if i != j:
            p[j] -= t[i]

for i in range(1, n+1):
    if p[i] > 0:
        print('Yes')
    else:
        print('No')


### FIXED CODE ###

n, k, q = map(int, input().split())

a = [-1] * q
for i in range(q):
    a[i] = int(input())

t = [0] * (n+1)
for i in range(q):
    t[ a[i] ] += 1

p = [0] * (n+1)
for i in range(1, n+1):
    p[i] = k - q + t[i]

for i in range(1, n+1):
    if p[i] > 0:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

def lcm(a, b):
    ax = a
    bx = b
    c = 0
    if a<b:
        ax, bx = (bx, ax)
    while True:
        if ax%bx == 0:
            gcd = bx
            break
        else:
            c = bx
            bx = ax%bx
            ax = c
    return a*b // gcd

n = int(input())
Mx = int(input())
lst = [Mx]
lst2 = []
for i in range(n-1):
    a = int(input())
    if Mx%a != 0:
        lst.append(a)
        lst.sort()
        if Mx<a:
            Mx = a

while True:
    y = len(lst)
    for i in range(y-1):
        lst2.append(lcm(lst[i], lst[i+1]))
    x = len(lst2)
    if x==1:
        print(lst2[0])
        break
    lst.clear()
    for i in range(x-1):
        lst.append(lcm(lst2[i], lst2[i+1]))
    y = len(lst)
    if y==1:
        print(lst[0])
        break
    lst2.clear()

### FIXED CODE ###

def lcm(a, b):
    ax = a
    bx = b
    if a<b:
        ax, bx = (bx, ax)
    while True:
        if ax%bx == 0:
            gcd = bx
            break
        else:
            c = bx
            bx = ax%bx
            ax = c
    return a*b // gcd

n = int(input())
lst = []
lst2 = []
for i in range(n):
    a = int(input())
    lst.append(a)

while True:    
    if n==1:
        print(lst[0])
        break
    lst2.append(lcm(lst[0], lst[1]))
    lst.pop(0)
    lst.pop(0)
    lst2.extend(lst)
    if len(lst2)==1:
        print(lst2[0])
        break
    lst.clear()
        
    lst.append(lcm(lst2[0], lst2[1]))
    lst2.pop(0)
    lst2.pop(0)
    lst.extend(lst2)
    if len(lst)==1:
        print(lst[0])
        break
    lst2.clear()
### BUGGY CODE ###

from sys import stdout
import bisect
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split()) 
DBG = True  and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
l = inl()
acc = 0
l.sort()
for i in range(n-2):
  a = l[i]
  for j in range(i+1,n-1):
    b = l[j]
    e = bisect.bisect_left(l,a+b)
    ddprint("a {} b {} i {} j {} e {}".format(a,b,i,j,e))
    acc += e-j-1
print(acc)


### FIXED CODE ###

from sys import stdout
import bisect
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split()) 
DBG = True  and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
l = inl()
acc = 0
l.sort()
for i in range(n-2):
  a = l[i]
  for j in range(i+1,n-1):
    b = l[j]
    e = bisect.bisect_left(l[j+1:],a+b)
    #ddprint("a {} b {} i {} j {} e {}".format(a,b,i,j,e))
    acc += e  #-j-1
print(acc)
### BUGGY CODE ###

import math

k = int(input())
sum_ = 0

for i in range(1, k+1):
    for j in range(1, k+1):
        for l in range(1, k+1):
            sum_ += math.gcd(math.gcd(i, j), l)
            
print(sum_)

### FIXED CODE ###

import math

k = int(input())
sum_ = 0

for i in range(1, k+1):
    for j in range(1, k+1):
        x = math.gcd(i, j)
        for l in range(1, k+1):
            sum_ += math.gcd(x, l)
            
print(sum_)
### BUGGY CODE ###



s = raw_input()
t = raw_input()

dp = [[0] * (len(t) + 1) for _ in range(len(s) + 1)]
for i in range(1, len(s) + 1):
    for j in range(1, len(t) + 1):
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])
        if s[i - 1] == t[j - 1]:
            dp[i][j] = max(dp[i][j], 1 + dp[i - 1][j - 1])
        else:
            dp[i][j] = max(dp[i][j], dp[i - 1][j - 1])

l = dp[len(s)][len(t)]
resp = []
inds = len(s)
indt = len(t)
while len(resp) < l:
    if s[inds - 1] == t[indt - 1] and dp[inds][indt] == 1 + dp[inds - 1][indt - 1]:
        resp.append(s[inds - 1])
        inds -= 1
        indt -= 1
        continue
    if dp[inds][indt] == dp[inds - 1][indt - 1]:
        inds -= 1
        indt -= 1
        continue
    if dp[inds][indt] == dp[inds - 1][indt]:
        inds -= 1
        continue
    if dp[inds][indt] == dp[inds][indt - 1]:
        indt -= 1
        continue
resp.reverse()
print(''.join(resp))


### FIXED CODE ###


s = raw_input()
t = raw_input()

dp = [[0] * (len(t) + 1) for _ in range(len(s) + 1)]
for i in range(1, len(s) + 1):
    for j in range(1, len(t) + 1):
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])
        if s[i - 1] == t[j - 1]:
            dp[i][j] = max(dp[i][j], 1 + dp[i - 1][j - 1])
        else:
            dp[i][j] = max(dp[i][j], dp[i - 1][j - 1])

l = dp[len(s)][len(t)]
resp = []
inds = len(s)
indt = len(t)
while len(resp) < l:
    if s[inds - 1] == t[indt - 1] and dp[inds][indt] == 1 + dp[inds - 1][indt - 1]:
        resp.append(s[inds - 1])
        inds -= 1
        indt -= 1
        continue
    if dp[inds][indt] == dp[inds - 1][indt - 1]:
        inds -= 1
        indt -= 1
        continue
    if dp[inds][indt] == dp[inds - 1][indt]:
        inds -= 1
        continue
    if dp[inds][indt] == dp[inds][indt - 1]:
        indt -= 1
        continue
resp.reverse()
print(''.join(resp))
### BUGGY CODE ###

import heapq
N, Q = (int(i) for i in input().split())
L = [0] * 2 * N
for i in range(N):
    S, T, X = (int(i) for i in input().split())
    L[2 * i] = (S-X, X, 1)
    L[2 * i + 1] = (T-X, X, 0)

L.sort(reverse=True)

Xs = set([])
XH = []
heapq.heapify(XH)
for i in range(Q):
    D = int(input())
    ans = 0
    while True:
        if L:
            t, X, f = L.pop()
            if t <= D:
                if f == 1:
                    Xs.add(X)
                    heapq.heappush(XH, X)
                else:
                    Xs.remove(X)
            else:
                L.append((t, X, f))
                break
        else:
            break
    if Xs:
        while XH[0] not in Xs:
            X = heapq.heappop(XH)
        print(XH[0])
    else:
        print("-1")

### FIXED CODE ###

import sys
input = sys.stdin.readline

import heapq
N, Q = (int(i) for i in input().split())
L = [0] * (2 * N + Q)
for i in range(N):
    S, T, X = (int(i) for i in input().split())
    L[2 * i] = (S-X, 1, X)
    L[2 * i + 1] = (T-X, -1, X)
for i in range(Q):
    D = int(input())
    L[2 * N + i] = (D, 2, 0)
L.sort()

Xs = set([])
XH = []
heapq.heapify(XH)
for t, f, X in L:
    if f == 1:
        Xs.add(X)
        heapq.heappush(XH, X)
    elif  f == -1:
        Xs.remove(X)
    else:
        if Xs:
            while XH[0] not in Xs:
                X = heapq.heappop(XH)
            print(XH[0])
        else:
            print("-1")
### BUGGY CODE ###

N = int(input())
list_A = []
for _ in range(N):
    A = int(input())
    list_A.append(A)
    
A = max(list_A)
index_A = list_A.index(A)
for i in range(N):
    if list_A[i] == A:
      list_B = sorted(list_A, reverse=True)
      B = list_B[1]
      print(B)
    else:
      print(A)


### FIXED CODE ###

N = int(input())
list_A = []

for _ in range(N):
    A = int(input())
    list_A.append(A)
    
A = max(list_A)
index_A = list_A.index(A)

list_B = sorted(list_A, reverse=True)
B = list_B[1]

for i in range(N):    
    if list_A[i] == A:
        print(B)
    else:
        print(A)
### BUGGY CODE ###

N = int(input())
T = [int(_) for _ in input().split()]
for i in range(N - 1):
    T[i + 1] += T[i]
T = [0] + T
V = [int(_) for _ in input().split()]
V = V
vel = [min(i / 2, T[-1] - i / 2) for i in range(2 * T[-1] + 1)]
for i in range(N):
    for j in range(2 * T[-1] + 1):
        vel[j] = min(vel[j],
                     max(V[i], -j / 2 + T[i] + V[i], j / 2 - T[i + 1] + V[i]))
print((2 * sum(vel) - vel[0] - vel[-1]) / 4)


### FIXED CODE ###

N = int(input())
T = [int(_) for _ in input().split()]
for i in range(N - 1):
    T[i + 1] += T[i]
T = [0] + T
V = [int(_) for _ in input().split()]
V = V
vel = [min(i / 2, T[-1] - i / 2) for i in range(2 * T[-1] + 1)]
for i in range(N):
    for j in range(2 * T[-1] + 1):
        vel[j] = min(vel[j],
                     max(V[i], -j / 2 + T[i] + V[i], j / 2 - T[i + 1] + V[i]))
print((2 * sum(vel) - vel[0] - vel[-1]) / 4)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

n = int(input())
l = [list(map(int,input().split())) for i in range(n)]

xcal = [[0]*n for i in range(1<<n)]
ycal = [[0]*n for i in range(1<<n)]

for i in range(1<<n):
    for j in range(n):
        xcal[i][j] = abs(l[j][0])
        ycal[i][j] = abs(l[j][1])
        for k in range(n):
            if (i>>k) & 1:
                xcal[i][j] = min(xcal[i][j],abs(l[j][0]-l[k][0]))
                ycal[i][j] = min(ycal[i][j],abs(l[j][1]-l[k][1]))
        
ans = [float("INF")]*(n+1)

for i in range(1<<n):
    count = 0
    for j in range(n):
        if i >> j & 1:
            count += 1
    j = i
    while j >= 0:
        j &= i
        cost = 0
        for k in range(n):
            if not (i>>k & 1):
                cost += min(xcal[j][k],ycal[i-j][k])*l[k][2]
        ans[count] = min(ans[count],cost)
        j -= 1

for i in ans:
    print(i)

### FIXED CODE ###

import sys
input = sys.stdin.readline
def main():
    n = int(input())
    l = [list(map(int,input().split())) for i in range(n)]

    xcal = [[0]*n for i in range(1<<n)]
    ycal = [[0]*n for i in range(1<<n)]

    for i in range(1<<n):
        for j in range(n):
            xcal[i][j] = abs(l[j][0])
            ycal[i][j] = abs(l[j][1])
            for k in range(n):
                if (i>>k) & 1:
                    xcal[i][j] = min(xcal[i][j],abs(l[j][0]-l[k][0]))
                    ycal[i][j] = min(ycal[i][j],abs(l[j][1]-l[k][1]))
            xcal[i][j] *= l[j][2]
            ycal[i][j] *= l[j][2]
    ans = [float("INF")]*(n+1)

    for i in range(1<<n):
        count = 0
        for j in range(n):
            if i >> j & 1:
                count += 1
        j = i
        while j >= 0:
            j &= i
            cost = 0
            for k in range(n):
                if not (i>>k & 1):
                    cost += min(xcal[j][k],ycal[i-j][k])
                if cost > ans[count]:
                    break
            ans[count] = min(ans[count],cost)
            j -= 1

    for i in ans:
        print(i)
if __name__ == "__main__":
    main()
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
sum = 1

for i in range(n):
    sum *= a[i]

if(sum > 1000000000000000000):
    print(-1)
    exit(0)

print(sum)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
sum = 1

for i in range(n):
    if a[i] == 0:
        print(0)
        exit(0)

for i in range(n):
    sum *= a[i]
    if(sum > 1000000000000000000):
        print(-1)
        exit(0)

print(sum)
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10**9)

n , m = map(int,input().split())

g = [[] for i in range(n)]

for _ in range(m):
  v1 , v2 = map(int,input().split())
  v1 -=1; v2 -=1
  g[v1].append(v2)
  
# finding longest path for vertice i
def dfs(i):
  temp = 0
  for nv in g[i]:
    temp = max(temp, dfs(nv)+1)
    
  return temp
  
# finding overall longest path  
res = 0  
for i in range(n):
  res = max(res, dfs(i))
  
print(res)

### FIXED CODE ###

import sys

sys.setrecursionlimit(10**9)

n , m = map(int,input().split())

g = [[] for i in range(n)]

dp = [-1] *n
for _ in range(m):
  v1 , v2 = map(int,input().split())
  v1 -=1; v2 -=1
  g[v1].append(v2)
  
# finding longest path for vertice i
def dfs(i):
  if dp[i]!=-1:
    return dp[i]
  temp = 0
  for nv in g[i]:
    temp = max(temp, dfs(nv)+1)
  
  dp[i]=temp
  return temp
  
# finding overall longest path  
res = 0  
for i in range(n):
  res = max(res, dfs(i))
  
print(res)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
from fractions import Fraction

def main(): 
    N = int(input())
    x = [int(i) for i in input().split()]

    MOD = 10**9+7

    answer = 0
    frac = 0
    for i in range(N-1):
        frac += Fraction(1,i+1)
        dist = (x[i+1] - x[i]) % MOD
        answer = (answer + dist * frac) % MOD
    for i in range(1,N):
        answer = (answer * i) % MOD

    print(int(answer))

if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline

# 1~nまでの逆元(mod m) O(n)
def mod_inv_list(n:int, m:int):
    # inv_t[i]: iの法mの下での逆元
    inv_t = [0] + [1]
    for i in range(2,n):
        inv_t += [inv_t[m % i] * (m - m//i) % m]
    return inv_t

def main():
    N = int(input())
    x = [int(i) for i in input().split()]
    MOD = 10**9 + 7

    inv_acum = mod_inv_list(N,MOD)
    for i in range(1,N):
        inv_acum[i] = (inv_acum[i] + inv_acum[i-1]) % MOD

    ans = 0
    for i in range(1,N):
        ans += (x[i] - x[i-1]) * inv_acum[i]
        ans %= MOD

    for i in range(1,N):
        ans = (ans * i) % MOD

    print(ans)

if __name__ == "__main__":
    main()
### BUGGY CODE ###

N=int(input())
a=[0 for i in range(N-1)]
b=[0 for i in range(N-1)]
c=[0 for i in range(N-1)]
G=[[0 for i in range(N)] for i in range(N)]
VL=[set() for i in range(N)]
for i in range(N-1):
    a[i],b[i],c[i]=map(int,input().split())
    a[i]-=1
    b[i]-=1
    G[a[i]][b[i]]+=c[i]
    G[b[i]][a[i]]+=c[i]
    VL[a[i]].add(b[i])
    VL[b[i]].add(a[i])
Q,K=map(int,input().split())
K-=1
x=[0 for i in range(Q)]
y=[0 for i in range(Q)]
for i in range(Q):
    x[i],y[i]=map(int,input().split())
    x[i]-=1
    y[i]-=1
d=[10**15 for i in range(N)]
d[K]=0
V=set(range(N))
while(len(V)>0):
    u=list(V)[0]
    for v in V:
        if d[u]>d[v]:
            u=v
    V-=set([u])
    for v in VL[u]:
        if d[v]>d[u]+G[u][v]:
            d[v]=d[u]+G[u][v]
for i in range(Q):
    print(d[x[i]]+d[y[i]])


### FIXED CODE ###

import queue
N=int(input())
a=[0 for i in range(N-1)]
b=[0 for i in range(N-1)]
c=[0 for i in range(N-1)]
VL=[dict() for i in range(N)]
for i in range(N-1):
    a[i],b[i],c[i]=map(int,input().split())
    a[i]-=1
    b[i]-=1
    VL[a[i]][b[i]]=c[i]
    VL[b[i]][a[i]]=c[i]
Q,K=map(int,input().split())
K-=1
x=[0 for i in range(Q)]
y=[0 for i in range(Q)]
for i in range(Q):
    x[i],y[i]=map(int,input().split())
    x[i]-=1
    y[i]-=1
reached=[False for i in range(N)]
dist=[0 for i in range(N)]
q=queue.Queue()
q.put(K)
reached[K]=True
while(not(q.empty())):
    r=q.get()
    for v in VL[r]:
        if not(reached[v]):
            q.put(v)
            dist[v]=VL[r][v]+dist[r]
            reached[v]=True
for i in range(Q):
    print(dist[x[i]]+dist[y[i]])
### BUGGY CODE ###

import numpy as np
def main():
    n = int(input())
    ans = 0
    for i in range(1,n+1):
        #print(np.arange(i,n+1,i),np.arange(i,n,i).sum())
        ans += np.arange(i,n+1,i).sum()

    print(ans)
main()

### FIXED CODE ###

def main():
    n = int(input())
    ans = 0
    for i in range(1,n+1):
        #print(range(i,n+1,i),sum(range(i,n+1,i)))
        ans += sum(range(i,n+1,i))

    print(ans)
main()
### BUGGY CODE ###

N, K = map(int, input().split())
S = input()
Rs = []
now = S[0]
count = -1

for i in range(N):
    if S[i] == now:
        count += 1
    else:
        Rs.append(count)
        count = 0
        now = S[i]
Rs.append(count)
for _ in range(K):
    if len(Rs) > 3:
        add = [Rs[0] + Rs[1] + Rs[2] + 2]
        add.extend(Rs[3:])
        Rs = add
    elif len(Rs) == 3:
        Rs = [Rs[0] + Rs[1] + Rs[2] + 2]
        break
    elif len(Rs) == 2:
        Rs = [Rs[0] + Rs[1] + 1]
        break
    else:
        break
print(sum(Rs))

### FIXED CODE ###

N, K = map(int, input().split())
S = input()
Rs = []
now = S[0]
count = -1
 
for i in range(N):
    if S[i] == now:
        count += 1
    else:
        Rs.append(count)
        count = 0
        now = S[i]
Rs.append(count)
ans = 0

if S[0] == S[N-1]:
    if K >= (len(Rs)-1) // 2:
        ans = N-1
    else:
        ans = sum(Rs) + 2 * K
else:
    if K >= len(Rs) // 2:
        ans = N-1
    else:
        ans = sum(Rs) + 2 * K
  
print(ans)
### BUGGY CODE ###

n,W=map(int,input().split())
w=[0]*n
v=[0]*n
for i in range(n):
  w[i],v[i]=map(int,input().split())
V=[[0]*(W+3) for i in range(n+1)]
for i in range(1,n+1):
  for j in range(1,W+3):
    if j-w[i-1]<0:
      V[i][j]=V[i-1][j]
    else:
      V[i][j]=max(V[i-1][j],V[i-1][j-w[i-1]]+v[i-1])
print(V[n][W])

### FIXED CODE ###

n,W=map(int,input().split())
w=[0]*n
v=[0]*n
for i in range(n):
  w[i],v[i]=map(int,input().split())
V=[[0]*(W+3) for i in range(n+1)]
for i in range(1,n+1):
  for j in range(1,W+3):
    if j-w[i-1]<0:
      V[i][j]=V[i-1][j]
    else:
      V[i][j]=max(V[i-1][j],V[i-1][j-w[i-1]]+v[i-1])
print(V[n][W])
### BUGGY CODE ###

import bisect
while True:
    n, m = map(int, input().split())
    if n == 0:
        break
    p = list(int(input()) for i in range(n))
    point = [] + p
    for i in p:
        for j in p:
            a = i + j
            if a <= m and a not in point:
                point.append(a)
    point.sort()
    maxp = 0
    for i in point:
        if m - i in point:
            print(m)
            break
        pp = i + point[bisect.bisect_left(point, m - i) - 1]
        if pp > maxp:
            maxp = pp
    else:
        print(maxp)


### FIXED CODE ###

import bisect
def main():
    while True:
        n, m = map(int, input().split())
        if n == 0:
            break
        p = [0] + list(int(input()) for i in range(n))
        point = []
        for i in range(n):
            for j in p[i:]:
                a = p[i] + j
                if a < m:
                    point.append(a)
        point.sort()

        print(max(i + point[bisect.bisect_left(point, m - i) - 1] for i in point))
            
if __name__=="__main__":
	main()
### BUGGY CODE ###

n = int(input())
P = list(map(int, input().split()))

counter = 1
for i in range(1,n):
    if all( x>= P[i] for x in  P[0:i] ):
        print

        counter +=1

print(counter)

### FIXED CODE ###

n = int(input())
P = list(map(int, input().split()))

minimum = float('inf')
ans = 0
for p in P:
    if p <=minimum:
        minimum = p
        ans += 1
print(ans)
### BUGGY CODE ###

n=int(input())
import sys
sys.setrecursionlimit(1000000)
def kaijo(n):
    if n==0:
        return(1)
    else:
        return(n*kaijo(n-1))
print(kaijo(n)%(10**9+7))


### FIXED CODE ###

n=int(input())
'''
import sys
sys.setrecursionlimit(1000000)
def kaijo(n):
    if n==0:
        return(1)
    else:
        n=n%(10**9+7)
        return(n*kaijo(n-1))
print(kaijo(n)%(10**9+7))
'''
ans=1
for i in range(1,n+1):
    ans=i*(ans%(10**9+7))
print(ans%(10**9+7))