#include <bits/stdc++.h>
using namespace std;
long long int v[1000007];
string s1[100005];
string s2[100005];
long long int dp1[1000000];
long long int dp2[1000000];
long long int len[1000000];
int main() {
  long long int i, j, k, l, m, n, r, x, y, t;
  cin >> n;
  for (i = 1; i <= n; i++) scanf("%I64d", &v[i]);
  dp1[1] = 0;
  dp2[1] = v[1];
  for (i = 2; i <= n; i++) {
    dp1[i] = -1;
    dp2[i] = -1;
  }
  char ch1[1000000];
  char ch2[1000000];
  for (i = 1; i <= n; i++) {
    scanf("%s", ch1);
    s1[i] = ch1;
    l = s1[i].length();
    s2[i] = s1[i];
    reverse(s2[i].begin(), s2[i].end());
  }
  for (i = 2; i <= n; i++) {
    if (len[i] < len[i - 1]) {
      cout << "-1";
      exit(0);
    }
  }
  for (i = 2; i <= n; i++) {
    if (dp1[i - 1] != -1) {
      x = s1[i - 1].compare(s1[i]);
      if (x <= 0) {
        dp1[i] = dp1[i - 1];
      }
      x = s1[i - 1].compare(s2[i]);
      if (x <= 0) {
        dp2[i] = dp1[i - 1] + v[i];
      }
    }
    if (dp2[i - 1] != -1) {
      x = s2[i - 1].compare(s1[i]);
      if (x <= 0) {
        if (dp2[i - 1] < dp1[i] || dp1[i] == -1) dp1[i] = dp2[i - 1];
      }
      x = s2[i - 1].compare(s2[i]);
      if (x <= 0) {
        if (dp2[i - 1] + v[i] < dp2[i] || dp2[i] == -1)
          dp2[i] = dp2[i - 1] + v[i];
      }
    }
  }
  if (dp1[n] == -1)
    x = 10000000000000000;
  else
    x = dp1[n];
  if (dp2[n] == -1)
    y = 10000000000000000;
  else
    y = dp2[n];
  x = min(x, y);
  if (x == 10000000000000000)
    cout << "-1";
  else
    cout << x;
}
