#include <bits/stdc++.h>
using namespace std;
std::mt19937 rnd(
    (int)std::chrono::steady_clock::now().time_since_epoch().count());
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 500000;
const int MAXM = 500000;
const int MAXCOL = 500000;
const int MAXID = 2 * MAXN;
int n, m, ncol;
int col[MAXN];
int e[MAXM][2];
vector<int> insideadj[MAXN];
vector<int> bycol[MAXCOL];
int nid;
int id[MAXN];
bool done[MAXN];
bool colbipartite[MAXCOL];
bool use[MAXID];
vector<int> uselst;
vector<int> outsideadj[MAXID];
bool seen[MAXID];
int side[MAXID];
long long solve() {
  for (int i = (0); i < (m); ++i) {
    int a = e[i][0], b = e[i][1];
    if (col[a] != col[b]) continue;
    insideadj[a].push_back(b), insideadj[b].push_back(a);
  }
  for (int i = (0); i < (n); ++i) bycol[col[i]].push_back(i);
  nid = 0;
  for (int i = (0); i < (n); ++i) done[i] = false;
  for (int c = (0); c < (ncol); ++c) {
    bool ok = true;
    for (int _ = (0); _ < (((int)(bycol[c]).size())); ++_) {
      int s = bycol[c][_];
      if (done[s]) continue;
      queue<int> q;
      q.push(s);
      id[s] = nid;
      done[s] = true;
      nid += 2;
      while (!q.empty()) {
        int at = q.front();
        q.pop();
        for (int i = (0); i < (((int)(insideadj[at]).size())); ++i) {
          int to = insideadj[at][i];
          assert(col[to] == c);
          if (done[to]) {
            if (id[to] == id[at]) ok = false;
          } else {
            id[to] = id[at] ^ 1;
            done[to] = true;
            q.push(to);
          }
        }
      }
    }
    colbipartite[c] = ok;
  }
  assert(nid <= 2 * n);
  int cntcolbipartite = 0;
  for (int c = (0); c < (ncol); ++c)
    if (colbipartite[c]) ++cntcolbipartite;
  long long ret = (long long)cntcolbipartite * (cntcolbipartite - 1) / 2;
  map<pair<int, int>, vector<int>> bicoledges;
  for (int i = (0); i < (m); ++i) {
    int a = e[i][0], b = e[i][1];
    if (col[a] == col[b]) continue;
    if (!colbipartite[col[a]] || !colbipartite[col[b]]) continue;
    int x = col[a], y = col[b];
    if (x > y) swap(x, y);
    bicoledges[make_pair(x, y)].push_back(i);
  }
  for (int i = (0); i < (nid); ++i) use[i] = false;
  for (auto it = bicoledges.begin(); it != bicoledges.end(); ++it) {
    int c1 = it->first.first, c2 = it->first.second;
    vector<int> edges = it->second;
    uselst.clear();
    for (int i = (0); i < (((int)(edges).size())); ++i) {
      int idx = edges[i];
      for (int j = (0); j < (2); ++j) {
        int a = id[e[idx][j]];
        if (!use[a]) use[a] = true, uselst.push_back(a);
      }
    }
    for (int i = (0); i < (((int)(edges).size())); ++i) {
      int idx = edges[i];
      int a = id[e[idx][0]], b = id[e[idx][1]];
      outsideadj[a].push_back(b), outsideadj[b].push_back(a);
    }
    for (int i = (0); i < (((int)(uselst).size())); ++i) {
      int a = uselst[i], b = a ^ 1;
      if (!use[b]) continue;
      if (b != a + 1) continue;
      outsideadj[a].push_back(b), outsideadj[b].push_back(a);
    }
    for (int i = (0); i < (((int)(uselst).size())); ++i) {
      int a = uselst[i];
      seen[a] = false;
      side[a] = -1;
    }
    bool ok = true;
    for (int _ = (0); _ < (((int)(uselst).size())); ++_) {
      int s = uselst[_];
      if (seen[s]) continue;
      queue<int> q;
      q.push(s);
      side[s] = 0;
      seen[s] = true;
      while (!q.empty()) {
        int at = q.front();
        q.pop();
        for (int i = (0); i < (((int)(outsideadj[at]).size())); ++i) {
          int to = outsideadj[at][i];
          if (seen[to]) {
            if (side[to] == side[at]) ok = false;
          } else {
            side[to] = 1 - side[at];
            seen[to] = true;
            q.push(to);
          }
        }
      }
    }
    if (!ok) --ret;
    for (int i = (0); i < (((int)(uselst).size())); ++i)
      use[uselst[i]] = false, outsideadj[uselst[i]].clear();
  }
  return ret;
}
void run() {
  scanf("%d%d%d", &n, &m, &ncol);
  for (int i = (0); i < (n); ++i) scanf("%d", &col[i]), --col[i];
  for (int i = (0); i < (m); ++i)
    for (int j = (0); j < (2); ++j) scanf("%d", &e[i][j]), --e[i][j];
  printf("%lld\n", solve());
}
int main() {
  run();
  return 0;
}
