import std.stdio, std.range, std.conv, std.string;
import std.algorithm.comparison, std.algorithm.iteration, std.algorithm.mutation, std.algorithm.searching, std.algorithm.setops, std.algorithm.sorting;

void main()
{
    readln();
    const auto targets = readln().strip.split.to!(long[]);
    long[] list;
    list.length = targets.length;

    int count;
    foreach(i; 0..targets.length) {
        while(true)
        {
            auto range = list[i..$].commonPrefix!"a!=b"(targets[i..$]);
            if(range == [])
                break;

            range[] += 1;
            count++;
        }
    }
    writeln(count);
}
