#include <bits/stdc++.h>
using namespace std;
const int N = 5e5;
const int oo = 1e9 + 5;
int du[] = {-1, 0, 0, 1};
int dv[] = {0, -1, 1, 0};
const long long mod = 1e9 + 7;
long long sqr(long long x) { return x * x; }
int getbit(int state, int i) { return ((state >> i) & 1); }
int n, m, k, c[N + 5];
long long res;
pair<int, int> edge[N + 5];
bool notok[N + 5];
vector<int> q;
struct Clara {
  int dad, col, len;
  Clara(int Dad = 0, int Col = 0, int Len = 0) {
    dad = Dad;
    col = Col;
    len = Len;
  }
} data[N + 5], pre[N + 5];
void getdad(int u) {
  q.push_back(u);
  if (data[u].dad == u) return;
  int v = data[u].dad;
  getdad(v);
  data[u] = Clara(data[v].dad, (data[v].col + data[u].len) % 2,
                  (data[u].len + data[v].len) % 2);
}
bool join(int u, int v) {
  getdad(u);
  getdad(v);
  if (data[u].dad == data[v].dad) {
    if (data[u].col == data[v].col) return false;
    return true;
  }
  data[data[v].dad] = Clara(data[u].dad, (data[u].col + data[v].len + 1) % 2,
                            (data[v].len + data[u].len + 1) % 2);
  return true;
}
bool cmp(pair<int, int> x, pair<int, int> y) {
  pair<int, int> tmp1 = pair<int, int>(c[x.first], c[x.second]);
  pair<int, int> tmp2 = pair<int, int>(c[y.first], c[y.second]);
  return tmp1 < tmp2;
}
void Reset() {
  for (int i = 0; i < q.size(); i++) data[q[i]] = pre[q[i]];
  q.clear();
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) cin >> c[i];
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    if (c[u] > c[v]) swap(u, v);
    edge[i] = pair<int, int>(u, v);
  }
  for (int i = 1; i <= n; i++) data[i] = Clara(i, 0, 0);
  sort(edge + 1, edge + 1 + m, cmp);
  for (int i = 1; i <= m; i++) {
    int u = edge[i].first, v = edge[i].second;
    if (c[u] != c[v]) continue;
    if (!join(u, v)) notok[c[u]] = true;
  }
  res = k;
  for (int i = 1; i <= res; i++) k -= notok[i];
  res = 1ll * k * (k - 1) / 2;
  for (int i = 1; i <= n; i++) getdad(i);
  for (int i = 1; i <= n; i++) pre[i] = data[i];
  for (int i = 1; i <= m; i++) {
    int u = edge[i].first, v = edge[i].second;
    if (c[u] == c[v] || notok[c[u]] || notok[c[v]]) continue;
    bool ok = false;
    int j;
    for (j = i; j <= m; j++) {
      int u1 = edge[j].first, v1 = edge[j].second;
      if (pair<int, int>(c[u], c[v]) != pair<int, int>(c[u1], c[v1])) break;
      if (!join(u1, v1)) ok = true;
    }
    i = j - 1;
    res -= ok;
    Reset();
  }
  cout << res;
  return 0;
}
