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: Time Limit Exceeded)

using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder_Answer
{
    class Program
    {
        const int mod = 1000000007;

        static void Main(string[] args)
        {
            int N = int.Parse(ReadLine());
            string[] Reader = ReadLine().Split();
            int[] Numbers = Reader.Select(s => int.Parse(s)).ToArray();
            
            int OK = 0;
            List<int> Watched = new List<int>();
            for (int i = 1; i < N; i++) 
            {
                Watched.Add(Numbers[i - 1]);
                Watched.Sort((a, b) => a - b);
                if (Numbers[i] <= Watched[0]) OK++;
            }

            WriteLine(OK + 1);
            ReadKey();
        }
    }

    public static class Extension
    {
        #region 拡張:bool
        public static int ToInt(this bool Bool) 
        {
            if (Bool) return 1;
            else return 0;
        }

        public static string ToString(this bool Bool, string TrueStr, string FalseStr) 
        {
            if (Bool) return TrueStr;
            else return FalseStr;
        }
        #endregion

        #region 拡張:int
        public static char ToAlphaBets_Small(this int Base) 
        {
            switch (Base) 
            {
                case 0:
                    return 'a';
                case 1:
                    return 'b';
                case 2:
                    return 'c';
                case 3:
                    return 'd';
                case 4:
                    return 'e';
                case 5:
                    return 'f';
                case 6:
                    return 'g';
                case 7:
                    return 'h';
                case 8:
                    return 'i';
                case 9:
                    return 'j';
                case 10:
                    return 'k';
                case 11:
                    return 'l';
                case 12:
                    return 'm';
                case 13:
                    return 'n';
                case 14:
                    return 'o';
                case 15:
                    return 'p';
                case 16:
                    return 'q';
                case 17:
                    return 'r';
                case 18:
                    return 's';
                case 19:
                    return 't';
                case 20:
                    return 'u';
                case 21:
                    return 'v';
                case 22:
                    return 'w';
                case 23:
                    return 'x';
                case 24:
                    return 'y';
                case 25:
                    return 'z';

                default:
                    return '0';
            }
        }

        public static char ToAlphaBets_Big(this int Base)
        {
            switch (Base)
            {
                case 0:
                    return 'A';
                case 1:
                    return 'B';
                case 2:
                    return 'C';
                case 3:
                    return 'D';
                case 4:
                    return 'E';
                case 5:
                    return 'F';
                case 6:
                    return 'G';
                case 7:
                    return 'H';
                case 8:
                    return 'I';
                case 9:
                    return 'J';
                case 10:
                    return 'K';
                case 11:
                    return 'L';
                case 12:
                    return 'M';
                case 13:
                    return 'N';
                case 14:
                    return 'O';
                case 15:
                    return 'P';
                case 16:
                    return 'Q';
                case 17:
                    return 'R';
                case 18:
                    return 'S';
                case 19:
                    return 'T';
                case 20:
                    return 'U';
                case 21:
                    return 'V';
                case 22:
                    return 'W';
                case 23:
                    return 'X';
                case 24:
                    return 'Y';
                case 25:
                    return 'Z';

                default:
                    return '0';
            }
        }
        #endregion

        #region 拡張:char
        public static int Toint(this char Char) 
        {
            switch (Char) 
            {
                case 'a':
                case 'A':
                    return 0;

                case 'b':
                case 'B':
                    return 1;

                case 'c':
                case 'C':
                    return 2;

                case 'd':
                case 'D':
                    return 3;

                case 'e':
                case 'E':
                    return 4;

                case 'f':
                case 'F':
                    return 5;

                case 'g':
                case 'G':
                    return 6;

                case 'h':
                case 'H':
                    return 7;

                case 'i':
                case 'I':
                    return 8;

                case 'j':
                case 'J':
                    return 9;

                case 'k':
                case 'K':
                    return 10;

                case 'l':
                case 'L':
                    return 11;

                case 'm':
                case 'M':
                    return 12;

                case 'n':
                case 'N':
                    return 13;

                case 'o':
                case 'O':
                    return 14;

                case 'p':
                case 'P':
                    return 15;

                case 'q':
                case 'Q':
                    return 16;

                case 'r':
                case 'R':
                    return 17;

                case 's':
                case 'S':
                    return 18;

                case 't':
                case 'T':
                    return 19;

                case 'u':
                case 'U':
                    return 20;

                case 'v':
                case 'V':
                    return 21;

                case 'w':
                case 'W':
                    return 22;

                case 'x':
                case 'X':
                    return 23;

                case 'y':
                case 'Y':
                    return 24;

                case 'z':
                case 'Z':
                    return 25;

                default:
                    return -1;
            }
        }

        public static char NextAlpha(this char Char) 
        {
            int AfterInt = Char.Toint() + 1;
            if (Char.ToString() == Char.ToString().ToLower()) return AfterInt.ToAlphaBets_Small();
            else return AfterInt.ToAlphaBets_Big();
                
        }
        #endregion
    }
}