# Shifty sort

**Computer Science**Level 5

Ayumu the chimp is given the task of sorting a group of integers \(a_{0},a_{1},a_{2},a_{3}..\) into a non-decreasing order. Unfortunately Ayumu can only perform one operation,a single shift. That is,he can only move the last element of a sequence to the beginning. \[a_{0},a_{1},a_{2} \ldots a_{n} \rightarrow a_{n},a_{0},a_{1} \ldots a_{n-1} \] Let \(F(a)\) be the minimum number of times Ayumu has to do the single shift so that the sequence \(a\) is sorted. If \(a\) cannot be sorted with the shift operation then \(F(a)\) is equal to \(-1\).

This text file contains **100** lines and in each line there is a sequence \(a\). Find the sum of \(F(a)\) for all the sequences in the text file.

**Explicit examples**

For the sequence \(a=[2,1]\) , \(F(a)=1\).

If \(a=[1] \) , \(F(a)=0\)

If \(a=[1,3,2]\) , \(F(a)=-1\)

If \(a=[1,2]\) , \(F(a)=0\)