output_description: Print the answer.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
attempt: # -*- coding: utf-8 -*-
  
  import sys
  
  
  def input():
      return sys.stdin.readline().strip()
  
  
  def list2d(a, b, c):
      return [[c] * b for i in range(a)]
  
  
  def list3d(a, b, c, d):
      return [[[d] * c for j in range(b)] for i in range(a)]
  
  
  def list4d(a, b, c, d, e):
      return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
  
  
  def ceil(x, y=1):
      return int(-(-x // y))
  
  
  def INT():
      return int(input())
  
  
  def MAP():
      return map(int, input().split())
  
  
  def LIST(N=None):
      return list(MAP()) if N is None else [INT() for i in range(N)]
  
  
  def Yes():
      print("Yes")
  
  
  def No():
      print("No")
  
  
  def YES():
      print("YES")
  
  
  def NO():
      print("NO")
  
  
  sys.setrecursionlimit(10**9)
  INF = 10**18
  MOD = 10**9 + 7
  
  
  class BIT:
      """Binary Indexed Tree"""
  
      def __init__(self, n):
          # 0-indexed
          n += 1
          nv = 1
          while nv < n:
              nv *= 2
          self.size = nv
          self.tree = [0] * nv
  
      def sum(self, i):
          """[0, i]を合計する"""
          s = 0
          i += 1
          while i > 0:
              s += self.tree[i - 1]
              i -= i & -i
          return s
  
      def add(self, i, x):
          """値の追加：添字i, 値x"""
          i += 1
          while i <= self.size:
              self.tree[i - 1] += x
              i += i & -i
  
      def get(self, l, r=None):
          """区間和の取得 [l, r)"""
          # 引数が1つなら一点の値を取得
          if r is None:
              r = l + 1
          res = 0
          if r:
              res += self.sum(r - 1)
          if l:
              res -= self.sum(l - 1)
          return res
  
  
  N = INT()
  A = LIST()
  
  bit = BIT(N)
  ans = 0
  for i in range(N):
      # 自分より左にある、自分より小さな数の個数
      if bit.sum(A[i]) == 0:
          ans += 1
      bit.add(A[i], 1)
  print(ans)
  
problem_description: Statement
  
  Given is a positive integer N.  
  Find the number of pairs (A, B) of positive integers not greater than N that
  satisfy the following condition:
  
    * When A and B are written in base ten without leading zeros, the last digit of A is equal to the first digit of B, and the first digit of A is equal to the last digit of B.
samples: [{"input": "25", "output": "17\n    \n\nThe following 17 pairs satisfy the condition: (1,1), (1,11), (2,2), (2,22),\n(3,3), (4,4), (5,5), (6,6), (7,7), (8,8), (9,9), (11,1), (11,11), (12,21),\n(21,12), (22,2), and (22,22).\n\n* * *"}, {"input": "1", "output": "1\n    \n\n* * *"}, {"input": "100", "output": "108\n    \n\n* * *"}, {"input": "2020", "output": "40812\n    \n\n* * *"}, {"input": "200000", "output": "400000008"}]