Problem:
Score : 300 points

Problem Statement

Given is a permutation P_1, \ldots, P_N of 1, \ldots, N.
Find the number of integers i (1 \leq i \leq N) that satisfy the following condition:

For any integer j (1 \leq j \leq i), P_i \leq P_j.

Constraints

1 \leq N \leq 2 \times 10^5

P_1, \ldots, P_N is a permutation of 1, \ldots, N.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
P_1 ... P_N

Output

Print the number of integers i that satisfy the condition.

Sample Input 1

5
4 2 5 1 3

Sample Output 1

3

i=1, 2, and 4 satisfy the condition, but i=3 does not - for example, P_i > P_j holds for j = 1.

Similarly, i=5 does not satisfy the condition, either. Thus, there are three integers that satisfy the condition.

Sample Input 2

4
4 3 2 1

Sample Output 2

4

All integers i (1 \leq i \leq N) satisfy the condition.

Sample Input 3

6
1 2 3 4 5 6

Sample Output 3

1

Only i=1 satisfies the condition.

Sample Input 4

8
5 7 4 2 6 8 1 3

Sample Output 4

4

Sample Input 5

1
1

Sample Output 5

1

Solution in C# (Mono 4.6.2.0) (judge verdict: Wrong Answer)

/*********************************************
* 20.05.11 AtCoder Beginner Contest 157. A, B, C
* 
*
*********************************************/

namespace TempName{
    using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.Reflection;
    using System.Text;
    using static System.Console;
    using static IOmacro.CSharpInput; 
    using static IOmacro.CppInput;
    using static IOmacro.CConst;

    public class CRun{
        public readonly char problem_num = 'C';
        
/*********************************************
A - AC or WA 
M이 N 이상인지 판별
*********************************************/
public void solve_A() {
    int N = cin;
    int M = cin;
    string ans = (M >= N ? "Yes" : "No");
    WriteLine(ans);
}

/*********************************************
B - Comparing Strings 
정수 a, b
정수 a를 b회 반복해 만드는 문자열과
정수 b를 a회 반복해 만드는 문자열 중
사전순으로 작은 문자 출력
*********************************************/
public void solve_B() {
    var x = new int[2]{cin, cin};
    if (x[0] > x[1]) {
        x[0] ^= x[1];
        x[1] ^= x[0];
        x[0] ^= x[1];
    }
    
    var ans = new StringBuilder();
    for (int i = 0; i < x[1]; i++) {
        ans.Append(x[0].ToString());
    }
    
    WriteLine(ans);
}

/*********************************************
C - Low Elements 
순열 P_N
다음을 만족하는 요소의 수는?
Pi <= Pj (1 <= j <= i <= N)
*********************************************/
public void solve_C() {
    int N = _int;
    int[] P = _inta;
    
    int ans = N;
    for (int i = 0; i < N - 1; i++) {
        if (P[i] < P[i + 1]) {
            ans--;
        }
    }
    
    WriteLine(ans);
}

/*********************************************

*********************************************/
public void solve_D() {
    
}

/*********************************************

*********************************************/
public void solve_E() {
    
}

/*********************************************

*********************************************/
public void solve_F() {
    
}

    }
    class Program { 
        static void Main() { 
            var run = new CRun();
            switch (run.problem_num) {
                case 'A': run.solve_A(); break;
                case 'B': run.solve_B(); break;
                case 'C': run.solve_C(); break;
                case 'D': run.solve_D(); break;
                case 'E': run.solve_E(); break;
                case 'F': run.solve_F(); break;
            }
        } 
    }
}

namespace IOmacro {
    //20.05.10. 수정
    
    using System; 
    using System.Linq; 
    using System.IO;
    using System.Collections.Generic;
    
    public class CSharpInput {
        public static StreamWriter _writer = new StreamWriter(Console.OpenStandardOutput());
        public const char separator = ' ';
        public static string _string{get{return Console.ReadLine();}}
        public static string[] _stringa{get{return (Console.ReadLine().Split(separator));}}
        public static int _int{get{return int.Parse(Console.ReadLine());}}
        public static int[] _inta{get{return Console.ReadLine().Split(separator).Select(int.Parse).ToArray();}}
        public static long _long{get{return long.Parse(Console.ReadLine());}}
        public static long[] _longa{get{return Console.ReadLine().Split(separator).Select(long.Parse).ToArray();}}    
        public static double _double{get{return double.Parse(Console.ReadLine());}}
        public static double[] _doublea{get{return Console.ReadLine().Split(separator).Select(double.Parse).ToArray();}}    
    }
    
    public class CConst {
        public static readonly int MINI = int.MaxValue;
        public static readonly long INF = Int64.MaxValue;
    }
    
    public class CppInput {
        public static CppInput cin => new CppInput();
        public const char separator = ' ';
        private static readonly Queue<string> _input = new Queue<string>();
        private CppInput(){}
        public static implicit operator string(CppInput _) {
            if (_input.Count == 0) Console.ReadLine().Split(separator).foreachExtension(x => _input.Enqueue(x));
            return _input.Dequeue();
        }
        public static implicit operator int(CppInput _){
            if (_input.Count == 0) Console.ReadLine().Split(separator).foreachExtension(x => _input.Enqueue(x));
            return int.Parse(_input.Dequeue());
        }
        public static implicit operator long(CppInput _){
            if (_input.Count == 0) Console.ReadLine().Split(separator).foreachExtension(x => _input.Enqueue(x));
            return long.Parse(_input.Dequeue());
        }
        public static implicit operator double(CppInput _){
            if (_input.Count == 0) Console.ReadLine().Split(separator).foreachExtension(x => _input.Enqueue(x));
            return double.Parse(_input.Dequeue());
        }
    }
    
    public static class EnumerableExtension {
        public delegate void Function<in T>(T val);
        public static void foreachExtension<T>(this IEnumerable<T> enumerable, Function<T> function) {
            foreach (var x in enumerable) function(x);
        }
    }
}