#include <bits/stdc++.h>
using namespace std;
long long int st[200000], rev[200000];
long long int ct[200000];
int main() {
  long long int MAXN = 2000000000000000000;
  long long int n, i, j, k, ans;
  cin >> n;
  char c[200000], b[200000], brev[200000], f[200000];
  for (i = 0; i < n; i++) {
    cin >> ct[i];
  }
  scanf("%s", &c);
  for (i = 0; i < n; i++) {
    rev[i] = MAXN;
    st[i] = MAXN;
  }
  rev[0] = ct[0];
  st[0] = 0;
  for (j = 0; c[j] != '\0'; j++) {
    b[j] = c[j];
  }
  j = strlen(c) - 1;
  k = 0;
  while (j >= 0) {
    brev[k++] = c[j];
    j--;
  }
  long long int flag = 0;
  for (i = 1; i < n; i++) {
    scanf("%s", &c);
    j = strlen(c) - 1;
    k = 0;
    while (j >= 0) {
      f[k++] = c[j];
      j--;
    }
    if (strcmp(c, b) >= 0) {
      st[i] = min(st[i - 1], st[i]);
    }
    if (strcmp(c, brev) >= 0) {
      st[i] = min(rev[i - 1], st[i]);
    }
    if (strcmp(f, b) >= 0) {
      rev[i] = min(st[i - 1] + ct[i], rev[i]);
    }
    if (strcmp(f, brev) >= 0) {
      rev[i] = min(rev[i - 1] + ct[i], rev[i]);
    }
    for (j = 0; b[j] != '\0'; j++) {
      b[j] = '\0';
    }
    for (j = 0; brev[j] != '\0'; j++) {
      brev[j] = '\0';
    }
    for (j = 0; c[j] != '\0'; j++) {
      b[j] = c[j];
    }
    j = strlen(c) - 1;
    k = 0;
    while (j >= 0) {
      brev[k++] = c[j];
      j--;
    }
  }
  ans = min(rev[n - 1], st[n - 1]);
  if (ans == MAXN) {
    cout << "-1";
  } else {
    cout << ans;
  }
}
