#include <bits/stdc++.h>
using namespace std;

// Find total number of pairs (i,j), i < j,
// such that (nums[i] + nums[j]) %5 ==0

int main()
{
    int n;
   
    int res = 0;

    cin >> n;

    vector<int> ar;

    for (int i = 0; i < n; i++)
    {
        int y;
        cin >> y;
        ar.push_back(y);
    }

    unordered_map<int, int> mp;


    for (int j = 0; j < n; j++)
    {
       int real=ar[j]%5;
       int r=5-real;
      r=r%5; //when a[j]=0 '(real numbers)we search for 5 which doesn't exist 
        if(mp.find(r)!=mp.end())
        {
          res+=mp[r];
         }
        mp[real]++;
    }

    cout << res << endl;

    return 0;
}