program atcoder322_D
  integer(8),dimension(200000) :: A,B
  integer(8)::M
  read(5,*)N
  read(5,*)A(1:N)
  M=0
  do I=1,N
     B(A(I))=B(A(I))+1
  end do
  do I=1,N
     M=M+B(I)*(B(I)-1)/2
  end do
  do I=1,N
     write(6,*)M-(B(A(I))-1)
  end do
end program atcoder322_D
; ModuleID = 'FIRModule'
source_filename = "FIRModule"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

@_QFEa = internal global [200000 x i64] undef
@_QFEb = internal unnamed_addr global [200000 x i64] undef
@_QQcl.3cce42c2215f1f7c2e48221988506342 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_2055/source.f\00"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

define void @_QQmain() local_unnamed_addr {
  %1 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %2 = alloca i32, align 4
  %3 = tail call ptr @_FortranAioBeginExternalListInput(i32 5, ptr nonnull @_QQcl.3cce42c2215f1f7c2e48221988506342, i32 4)
  %4 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %2, i32 4)
  %5 = call i32 @_FortranAioEndIoStatement(ptr %3)
  %6 = call ptr @_FortranAioBeginExternalListInput(i32 5, ptr nonnull @_QQcl.3cce42c2215f1f7c2e48221988506342, i32 5)
  %7 = load i32, ptr %2, align 4, !tbaa !3
  %8 = call i32 @llvm.smax.i32(i32 %7, i32 0)
  %9 = zext i32 %8 to i64
  store ptr @_QFEa, ptr %1, align 8, !tbaa !7
  %.fca.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 1
  store i64 8, ptr %.fca.1.gep, align 8, !tbaa !7
  %.fca.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 2
  store i32 20180515, ptr %.fca.2.gep, align 8, !tbaa !7
  %.fca.3.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 3
  store i8 1, ptr %.fca.3.gep, align 4, !tbaa !7
  %.fca.4.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 4
  store i8 10, ptr %.fca.4.gep, align 1, !tbaa !7
  %.fca.5.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 5
  store i8 0, ptr %.fca.5.gep, align 2, !tbaa !7
  %.fca.6.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 6
  store i8 0, ptr %.fca.6.gep, align 1, !tbaa !7
  %.fca.7.0.0.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 0
  store i64 1, ptr %.fca.7.0.0.gep, align 8, !tbaa !7
  %.fca.7.0.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 1
  store i64 %9, ptr %.fca.7.0.1.gep, align 8, !tbaa !7
  %.fca.7.0.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 2
  store i64 8, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  %10 = call i1 @_FortranAioInputDescriptor(ptr %6, ptr nonnull %1)
  %11 = call i32 @_FortranAioEndIoStatement(ptr %6)
  %12 = load i32, ptr %2, align 4, !tbaa !3
  %13 = sext i32 %12 to i64
  %14 = icmp sgt i32 %12, 0
  br i1 %14, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %0
  %xtraiter = and i64 %13, 1
  %15 = icmp eq i32 %12, 1
  br i1 %15, label %.preheader12.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %13, -2
  br label %.lr.ph

.preheader12.unr-lcssa.loopexit:                  ; preds = %.lr.ph
  %16 = add nuw nsw i64 %indvars.iv, 1
  br label %.preheader12.unr-lcssa

.preheader12.unr-lcssa:                           ; preds = %.preheader12.unr-lcssa.loopexit, %.lr.ph.preheader
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %16, %.preheader12.unr-lcssa.loopexit ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader12, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %.preheader12.unr-lcssa
  %17 = getelementptr [200000 x i64], ptr @_QFEa, i64 0, i64 %indvars.iv.unr
  %18 = load i64, ptr %17, align 8, !tbaa !3
  %19 = add i64 %18, -1
  %20 = getelementptr [200000 x i64], ptr @_QFEb, i64 0, i64 %19
  %21 = load i64, ptr %20, align 8, !tbaa !3
  %22 = add i64 %21, 1
  store i64 %22, ptr %20, align 8, !tbaa !3
  br label %.preheader12

.preheader12:                                     ; preds = %.preheader12.unr-lcssa, %.lr.ph.epil
  br i1 %14, label %.lr.ph14.preheader, label %._crit_edge

.lr.ph14.preheader:                               ; preds = %.preheader12
  %min.iters.check = icmp ult i32 %12, 4
  br i1 %min.iters.check, label %.lr.ph14.preheader28, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph14.preheader
  %n.vec = and i64 %13, -4
  %ind.end = or i64 %n.vec, 1
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %31, %vector.body ]
  %vec.phi26 = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %32, %vector.body ]
  %23 = getelementptr [200000 x i64], ptr @_QFEb, i64 0, i64 %index
  %wide.load = load <2 x i64>, ptr %23, align 16, !tbaa !3
  %24 = getelementptr i64, ptr %23, i64 2
  %wide.load27 = load <2 x i64>, ptr %24, align 16, !tbaa !3
  %25 = add <2 x i64> %wide.load, <i64 -1, i64 -1>
  %26 = add <2 x i64> %wide.load27, <i64 -1, i64 -1>
  %27 = mul <2 x i64> %25, %wide.load
  %28 = mul <2 x i64> %26, %wide.load27
  %29 = sdiv <2 x i64> %27, <i64 2, i64 2>
  %30 = sdiv <2 x i64> %28, <i64 2, i64 2>
  %31 = add <2 x i64> %29, %vec.phi
  %32 = add <2 x i64> %30, %vec.phi26
  %index.next = add nuw i64 %index, 4
  %33 = icmp eq i64 %index.next, %n.vec
  br i1 %33, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <2 x i64> %32, %31
  %34 = call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %bin.rdx)
  %cmp.n = icmp eq i64 %n.vec, %13
  br i1 %cmp.n, label %.preheader, label %.lr.ph14.preheader28

.lr.ph14.preheader28:                             ; preds = %.lr.ph14.preheader, %middle.block
  %indvars.iv17.ph = phi i64 [ 1, %.lr.ph14.preheader ], [ %ind.end, %middle.block ]
  %.013.ph = phi i64 [ 0, %.lr.ph14.preheader ], [ %34, %middle.block ]
  br label %.lr.ph14

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 1, %.lr.ph.preheader.new ], [ %indvars.iv.next.1, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.1, %.lr.ph ]
  %35 = add nsw i64 %indvars.iv, -1
  %36 = getelementptr [200000 x i64], ptr @_QFEa, i64 0, i64 %35
  %37 = load i64, ptr %36, align 8, !tbaa !3
  %38 = add i64 %37, -1
  %39 = getelementptr [200000 x i64], ptr @_QFEb, i64 0, i64 %38
  %40 = load i64, ptr %39, align 8, !tbaa !3
  %41 = add i64 %40, 1
  store i64 %41, ptr %39, align 8, !tbaa !3
  %42 = getelementptr [200000 x i64], ptr @_QFEa, i64 0, i64 %indvars.iv
  %43 = load i64, ptr %42, align 8, !tbaa !3
  %44 = add i64 %43, -1
  %45 = getelementptr [200000 x i64], ptr @_QFEb, i64 0, i64 %44
  %46 = load i64, ptr %45, align 8, !tbaa !3
  %47 = add i64 %46, 1
  store i64 %47, ptr %45, align 8, !tbaa !3
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %.preheader12.unr-lcssa.loopexit, label %.lr.ph

.preheader:                                       ; preds = %.lr.ph14, %middle.block
  %.lcssa = phi i64 [ %34, %middle.block ], [ %55, %.lr.ph14 ]
  %48 = add i64 %.lcssa, 1
  br i1 %14, label %.lr.ph15, label %._crit_edge

.lr.ph14:                                         ; preds = %.lr.ph14.preheader28, %.lr.ph14
  %indvars.iv17 = phi i64 [ %indvars.iv.next18, %.lr.ph14 ], [ %indvars.iv17.ph, %.lr.ph14.preheader28 ]
  %.013 = phi i64 [ %55, %.lr.ph14 ], [ %.013.ph, %.lr.ph14.preheader28 ]
  %49 = add nsw i64 %indvars.iv17, -1
  %50 = getelementptr [200000 x i64], ptr @_QFEb, i64 0, i64 %49
  %51 = load i64, ptr %50, align 8, !tbaa !3
  %52 = add i64 %51, -1
  %53 = mul i64 %52, %51
  %54 = sdiv i64 %53, 2
  %55 = add i64 %54, %.013
  %indvars.iv.next18 = add nuw nsw i64 %indvars.iv17, 1
  %exitcond20.not = icmp eq i64 %indvars.iv17, %13
  br i1 %exitcond20.not, label %.preheader, label %.lr.ph14, !llvm.loop !12

.lr.ph15:                                         ; preds = %.preheader, %.lr.ph15
  %indvars.iv21 = phi i64 [ %indvars.iv.next22, %.lr.ph15 ], [ 1, %.preheader ]
  %56 = call ptr @_FortranAioBeginExternalListOutput(i32 6, ptr nonnull @_QQcl.3cce42c2215f1f7c2e48221988506342, i32 14)
  %57 = add nsw i64 %indvars.iv21, -1
  %58 = getelementptr [200000 x i64], ptr @_QFEa, i64 0, i64 %57
  %59 = load i64, ptr %58, align 8, !tbaa !3
  %60 = add i64 %59, -1
  %61 = getelementptr [200000 x i64], ptr @_QFEb, i64 0, i64 %60
  %62 = load i64, ptr %61, align 8, !tbaa !3
  %63 = sub i64 %48, %62
  %64 = call i1 @_FortranAioOutputInteger64(ptr %56, i64 %63)
  %65 = call i32 @_FortranAioEndIoStatement(ptr %56)
  %indvars.iv.next22 = add nuw nsw i64 %indvars.iv21, 1
  %exitcond24.not = icmp eq i64 %indvars.iv21, %13
  br i1 %exitcond24.not, label %._crit_edge, label %.lr.ph15

._crit_edge:                                      ; preds = %.lr.ph15, %0, %.preheader12, %.preheader
  ret void
}

declare ptr @_FortranAioBeginExternalListInput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioInputInteger(ptr, ptr, i32) local_unnamed_addr

declare i32 @_FortranAioEndIoStatement(ptr) local_unnamed_addr

declare i1 @_FortranAioInputDescriptor(ptr, ptr) local_unnamed_addr

declare ptr @_FortranAioBeginExternalListOutput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger64(ptr, i64) local_unnamed_addr

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i64 @llvm.vector.reduce.add.v2i64(<2 x i64>) #1

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(none) }

!llvm.module.flags = !{!0, !1, !2}

!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{!4, !4, i64 0}
!4 = !{!"any data access", !5, i64 0}
!5 = !{!"any access", !6, i64 0}
!6 = !{!"Flang Type TBAA Root"}
!7 = !{!8, !8, i64 0}
!8 = !{!"descriptor member", !5, i64 0}
!9 = distinct !{!9, !10, !11}
!10 = !{!"llvm.loop.isvectorized", i32 1}
!11 = !{!"llvm.loop.unroll.runtime.disable"}
!12 = distinct !{!12, !11, !10}
