#include <bits/stdc++.h>
using namespace std;
long long v[100010] = {}, dp[100010][2] = {};
int main() {
  long long n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
    dp[i][1] = (long long)1e18;
    dp[i][0] = (long long)1e18;
  }
  dp[1][0] = 0;
  dp[1][1] = v[1];
  vector<string> a;
  vector<string> tp;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    string h(s);
    a.push_back(s);
    reverse(h.begin(), h.end());
    tp.push_back(h);
  }
  for (int i = 2; i <= n; i++) {
    if (a[i - 1] >= a[i - 2]) dp[i][0] = min(dp[i][0], dp[i - 1][0]);
    if (a[i - 1] >= tp[i - 2]) dp[i][0] = min(dp[i][0], dp[i - 1][1]);
    if (tp[i - 1] >= a[i - 2]) dp[i][1] = min(dp[i][1], dp[i - 1][0] + v[i]);
    if (tp[i - 1] >= tp[i - 2]) dp[i][1] = min(dp[i][1], dp[i - 1][1] + v[i]);
  }
  long long ans = min(dp[n][0], dp[n][1]);
  if (ans != (long long)1e18)
    cout << ans << '\n';
  else
    cout << -1 << '\n';
  return 0;
}
